maciek2791 maciek2791 - 2 months ago 53x
Python Question

Run sqoop in python script

I'm trying to run sqoop command inside Python script. I had no problem to do that trough shell command, but when I'm trying to execute python stript:

sqoopcom="sqoop import --direct --connect abcd --username abc --P --query "queryname" "

exec (sqoopcom)

I got an error, Invalid syntax, how to solve it ?


The build in exec statement that you're using is for interpreting python code inside a python program.

What you want is to execute an external (shell) command. For that you could use call from the subprocess module

import subprocess["echo", "Hello", "World"])