下面是我用python编写的sqoop代码的链接:
https://bitbucket.org/factorsense/programming/src/master/python/rdbms_bigdata%20migration/sqoop_oracle_hdfs_incremental.py
在其中一部分中,我创建了一个sqoop命令列表,该命令将在linux服务器中执行:
def sqoop_job(table_name):
# The last value which was loaded into the Data Hub is picked from the SQOOP Audit Table which holds the details from the last run.
lastvalue =last_value(table_name)
# Last Update Date is fetched from the source and this is also updated into the SQOOP Audit Table.
last_update_date = max_load_date(table_name)
# print(last_update_date)
init_query = create_query(table_name)
final_query = init_query+"'"+lastvalue+"'"+','+"'"+"DD/MM/YYYY HH24:MI:SS""'"+')'+' AND $CONDITIONS'
print(final_query)
cmd = ['sqoop', 'import', '-Dhadoop.security.credential.provider.path='+alias_provider, '--connect', oracle_url, '--username', username,'--password-alias', password_alias,'-m', '1', '--as-textfile','--target-dir', target_dir_incr+'/'+table_name, '--query',final_query]
#
问题是,在查询中,列表会打印转义字符:
['sqoop', 'import', u'-Dhadoop.security.credential.provider.path=jceks://hdfs/tmp/symf.password.jceks', '--connect', u'jdbc:oracle:thin:@sl09.atradiusnet.com:1519/SYMF.atradiusnet.com', '--username', u'NLSMAY1', '--password-alias', u'symf.db.alias', '-m', '1', '--as-textfile', '--target-dir', u'/user/incoming_data/native_zone/symphony/incremental/TBOR_CURRENCY_EXCHANGE_RATES', '--query', u'"select ORCUY_CODE,ORCUY_CODE_BASE,TYP,EFFECT_TO_DAT,ORSUS_ID,EFFECT_FROM_DAT,AMT,LAST_UPDATE_DAT,LAST_UPDATE_SEQ ,current_timestamp, \'NLSMAY1\' from ORABUP0.TBOR_CURRENCY_EXCHANGE_RATES a where last_update_dat > to_timestamp(\'05/10/2018 15:13:05\',\'DD/MM/YYYY HH24:MI:SS\') AND $CONDITIONS']
现在,查询部分在oracle数据库中使用转义字符执行,但在oracle中失败:
Executing SQL statement: "select BUPIY_ID,EFFECT_FROM_DAT,EFFECT_TO_DAT,BUSINESS_TYP,ORSUS_ID,LAST_UPDATE_DAT ,current_timestamp, \'NLSMAY1\' from ORABUP0.TBPO_POL_BUSINESS_TYPES a where last_update_dat > to_timestamp(\'12/10/2018 20:42:59\',\'DD/MM/YYYY HH24:MI:SS\') AND (1 = 0)
有人能帮我解决这个问题吗?
暂无答案!
目前还没有任何答案,快来回答吧!