tnsnames.ora文件的位置不要放错了,是在network/admin目录下。还有里面的内容一定要顶格写,不能有缩进,否则会报错ORA-12154: TNS:could not resolve the connect identifier specified。这个文件中有四个参数需要改,第一行的名字DESCRIPTION,还有服务器名,端口号,还有SERVICE_NAME,其中DESCRIPTION和SERVICE_NAME最好一致。配置如下:
Collecting scrapy Could not fetch URLhttps://pypi.python.org/simple/scrapy/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping Could not find aversion that satisfies the requirement scrapy (from versions: ) No matching distribution found for scrapy
相关软件版本 python:2.7 pip:9.0.1 OSX Sierra 10.12.6 解决方法:
val argArray = spark.sparkContext.getConf.get("spark.driver.args").split("\\s+") print(argArray) val logs = spark.read.json(argArray(0)).select("cats") logs.cache() logs.createOrReplaceTempView("tracker")
val sql1 = "select count(1) from tracker where cats.cat='store' and cats.act='aa'" spark.sql(sql1).show(false)
val sql2 = "select count(1) from (select explode(cats) cats from tracker ) where cats.cat='store' and cats.act='bb'" spark.sql(sql1).show(false) spark.close()
vim /etc/profile exportLD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH source /etc/profile
5.创建一个a.py文件
1 2 3
import cx_Oracle con = cx_Oracle.connect('eqxiu_dev/keqs123@test.db.hohode.cn/oragbk') printcon.version
6.测试是否成功
1
python a.py
如果出现类似如下的版本号,说明成功了。
1
10.2.0.4.0
日期比较和查询表中所有字段
1 2 3 4 5 6 7 8 9 10 11 12 13
import cx_Oracle con = cx_Oracle.connect('username/password@host/server') printcon.version cur = con.cursor() cur.execute("select * from base_user where REG_TIME >= to_date('2018-08-08 00:00:00','yyyy-mm-dd hh24:mi:ss') and rownum<20 ") for result in cur: print result
columnsnames = cur.execute("select COLUMN_NAME from user_tab_columns where TABLE_NAME='BASE_USER'").fetchall() for name in columnsnames: print name cur.close() con.close()
18/06/28 11:37:35 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECTMIN(`id`), MAX(`id`) FROM`base_user` 18/06/2811:37:35 WARN db.TextSplitter: Generating splits for a textual index column. 18/06/2811:37:35 WARN db.TextSplitter: If your database sorts in a case-insensitive order, this may resultin a partialimportorduplicate records. 18/06/2811:37:35 WARN db.TextSplitter: You are strongly encouraged tochoose an integral split column. 18/06/2811:37:35 INFO mapreduce.JobSubmitter: numberof splits:6