maciek2791 maciek2791 - 1 year ago 651
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 ?

Answer Source

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"])

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download