Search code examples
pythonsqoop

How to import MySQL data using Sqoop in Python?


This is the code I wrote in terminal and works perfectly fine.

sqoop import --connect jdbc:mysql://localhost/testDb --username Amel -password Amel@-1998 --table mock3

I want to do the same thing but on PyCharm. What setting or lines of code should I use?

I'm quite new and I've been doing plenty of research but I can't find a relevant answer.


Solution

  • You can execute your commands by calling os.system() or subprocess.call()

    import subprocess
    subprocess.call(["echo", "Hello", "World"])  # substitute your command as an array of strings
    
    import os
    os.system("echo Hello World")  #  substitute your command
    

    There is also a library called pysqoop to use sqoop, check details from here. Your IDE (Pycharm) does not affect the solution.