Reputation: 31
Hello I'm getting this error while trying to save a Pandas dataframe into the ibm db2 database:
Can't load plugin: 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
Upvotes: 3
Views: 6602
Reputation: 12287
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.
IF you are connecting to Db2-for-Linux/Unix/Windows, you do not need to install other IBM software or licence files.
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. 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. 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. 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.
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). Refer to IBM's instructions for deploying the licence file to the correct location where the clidriver can use it.
Upvotes: 3