[英]Error while trying to connect to ibm db2 database through pandas: Can't load plugin: sqlalchemy.dialects:ibm_db_sa
Hello I'm getting this error while trying to save a Pandas dataframe into the ibm db2 database:您好,我在尝试将 Pandas 数据帧保存到 ibm db2 数据库时遇到此错误:
Can't load plugin: sqlalchemy.dialects:ibm_db_sa
无法加载插件:sqlalchemy.dialects:ibm_db_sa
I tried this solution but is does not work:我试过这个解决方案,但不起作用:
df = pd.read_csv('https://data.cityofchicago.org/resource/jcxq-k9xf.csv')
engine = sqlalchemy.create_engine('ibm_db_sa://'+ dsn_uid + ':' + dsn_pwd + '@'+dsn_hostname+':'+dsn_port+'/' + dsn_database )
chicago_socioeconomic_dataSQL = df.to_sql('chicago_socioeconomic_data', engine, if_exists = 'append', index=False)
Anybody can help me?任何人都可以帮助我吗?
Thank you, Matteo谢谢你,马特奥
Resolved by installing the required pre-requisite module ( ibm_db_sa ) which will also install the ibm_db module and the ibm_db_dbi module, and (by default, unless otherwise directed) will also install the Db2 ODBC and CLI driver
into your site_packages tree.通过安装所需的先决条件模块 ( ibm_db_sa ) 解决,该模块还将安装ibm_db模块和ibm_db_dbi模块,并且(默认情况下,除非另有指示)还将
Db2 ODBC and CLI driver
安装到您的 site_packages 树中。
IF you are connecting to Db2-for-Linux/Unix/Windows, you do not need to install other IBM software or licence files.如果您要连接到 Db2-for-Linux/Unix/Windows,则不需要安装其他 IBM 软件或许可证文件。
If you are connecting directly to Db2-for-i-series (AS/400) , from either Microsoft-Windows, or Linux, then you should first install 'IBM i access' with the optional ODBC/CLI support, and get it configured to connect to your Db2 for i.如果您从 Microsoft-Windows 或 Linux 直接连接到 Db2-for-i-series (AS/400),那么您应该首先安装带有可选 ODBC/CLI 支持的“IBM i access”,并对其进行配置连接到您的 Db2 for i。 Refer to its documentation for details.
有关详细信息,请参阅其文档。 Set the IBM_DB_HOME environment variable to point to the directory where the 'IBM i access' components are installed.
将IBM_DB_HOME环境变量设置为指向安装“IBM i access”组件的目录。 It is this environment variable that will tell the
ibm_db
module to not install the regular ODBC/CLI driver and to use your IBM i access
components instead.正是这个环境变量将告诉
ibm_db
模块不要安装常规的 ODBC/CLI 驱动程序,而是使用您的IBM i access
组件。 Then you can install the ibm_db_sa
module which will then use your 'IBM i access' product to communicate with the i-series database.然后您可以安装
ibm_db_sa
模块,该模块将使用您的“IBM i access”产品与 i 系列数据库进行通信。
If you are connecting directly to Db2 for Z/OS, you will be unable to connect without a licence file for Db2-connect, OR you can connect indirectly via a separate Db2-connect gateway (in which case you do not then need to deploy a separate licence file).如果您直接连接到 Db2 for Z/OS,则没有 Db2-connect 的许可证文件将无法连接,或者您可以通过单独的 Db2-connect 网关间接连接(在这种情况下,您不需要部署一个单独的许可证文件)。 Refer to IBM's instructions for deploying the licence file to the correct location where the clidriver can use it.
请参阅 IBM 的说明,将许可证文件部署到 clidriver 可以使用的正确位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.