I'm having trouble connecting to my database BLUDB in IBM Db2 on Cloud using SQLAlchemy. Here is the code I've always used and it's always worked fine:
%sql ibm_db_sa://user:[email protected]:50000/BLUDB
But now I get this error:
(ibm_db_dbi.ProgrammingError) ibm_db_dbi::ProgrammingError: Exception('[IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004\r SQLCODE=-1042') (Background on this error at: http://sqlalche.me/e/13/f405) Connection info needed in SQLAlchemy format, example: postgresql://username:password@hostname/dbname or an existing connection: dict_keys([])
These packages are loaded as always:
import ibm_dbimport ibm_db_saimport sqlalchemyfrom sqlalchemy.engine import create_engine
I looked at the python db2 documentation on ibm and the sqlalchemy error message but couldn't get anywhere.
I am working in Jupyterlab locally. I've recently reinstalled Python and Jupyterlab. That's the only thing locally that's changed.
I am able to successfully run the notebooks in the cloud at kaggle and cognitive class. I am also able to connect and query sqlite3 via python without an issue using my local notebook.
All the ibm modules and version numbers are the same before and after installation. I used requirements.txt for reinstallation.
In db2diag.log here are the last two entries:
2020-11-05-14.06.47.081000-300 I13371F372 LEVEL: Warning PID : 17500 TID : 7808 PROC : python.exe INSTANCE: NODE : 000 HOSTNAME: DESKTOP-6FFFO2E EDUID : 7808 FUNCTION: DB2 UDB, bsu security, sqlexLogPluginMessage, probe:20 DATA #1 : String with size, 43 bytes loadAuthidMapper: GetModuleHandle rc = 126
2020-11-05-14.13.49.282000-300 I13745F373 LEVEL: Warning PID : 3060 TID : 12756 PROC : python.exe INSTANCE: NODE : 000 HOSTNAME: DESKTOP-6FFFO2E EDUID : 12756 FUNCTION: DB2 UDB, bsu security, sqlexLogPluginMessage, probe:20 DATA #1 : String with size, 43 bytes loadAuthidMapper: GetModuleHandle rc = 126
pip listoutput from both before and after. The SQL1042C can happen due to a broken configuration on the client side. There may be more details in thedb2diag.logon the client workstation, study that and update the question with details. IF there are no details there, you can usedb2trcto get a CLI trace and it (after formatting ) will show what is going on under the covers. Refer to the Db2 Knowledge centre online for details. - maopip install ibm_db. Suggest you configuredb2dsdriver.cfgfile per Db2-Knowledge-Centre instructions, then usedb2cli validate -connect -dsn $YOURDSN -user $YOURUSER -passwd $YOURPASSWD. This eliminates python and jupyterlab temporarily and just gets the Db2-connection working at CLIDRIVER level. If that gives SQL1042C, then you can usedb2trcto see what is happening under the covers. Follow Db2-Knowledge-Centre instructions. - mao