如何在Python中使用Sqoop导入MySQL数据?

2024-06-28 19:10:54 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我在terminal中编写的代码,工作非常好

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

我想做同样的事情,但我的魅力。我应该使用什么设置或代码行

我是个新手,我做了很多研究,但我找不到相关的答案


Tags: 代码importlocalhostconnectmysqltableusernamepassword
1条回答
网友
1楼 · 发布于 2024-06-28 19:10:54

您可以通过调用os.system()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

还有一个名为pysqoop的库要使用sqoop,请从here检查详细信息。您的IDE(Pycharm)不会影响解决方案

相关问题 更多 >