Indrajit Swain Indrajit Swain - 2 months ago 38
Python Question

Run Sqoop with python 3 using subprocess

I am trying to run Sqoop command with python

subprocess.call(["sqoop","import","--connect", "jdbc:oracle:thin:@hostname:1521/ARSMTREP","--username", "username" ,"--password", "password","--table","ARADMIN."+line,"--as-textfile","--target-dir","/data/"+line])


able to execute this code but when I am trying to execute with "--fields-terminated-by"+" "+"'~'" it's giving tool import error

process=subprocess.call(["sqoop","import","--connect", "jdbc:oracle:thin:@hostname:1521/ARSMTREP","--username", "hadoop_user" ,"--password", "password","--table","ARADMIN."+line,"--fields-terminated-by"+" "+"'~'","--as-textfile","--target-dir","/data/"+line])



Error parsing arguments for import

Answer

Try:

process=subprocess.call(["sqoop","import","--connect", "jdbc:oracle:thin:@hostname:1521/ARSMTREP","--username", "hadoop_user" ,"--password", "password","--table","ARADMIN."+line,"--fields-terminated-by","'~'","--as-textfile","--target-dir","/data/"+line])

Comments