[Python] I need correct library setup to make a Python connection to DB2

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I am on Windows 11, Python 3.12.2 installed. After many failures of my script to connect to DB2 after installing ibm_db I noted that a milestone is to get a connection using just db2cli which is independent of Python and make it work. Then supposedly I would be home free by just using the connection string that the 'validate' command generated from DB2CLI. I finally got DB2CLI VAlIDATE to work and make a connection to DB2 on the mainframe. But plugging the resultant connection string into my Python still did not succeed. The string is as shown from the successful connection with db2cli:

    Connection attempt for data source name "xxxxxxxx":
    ===============================================================================

    [SUCCESS]

    Output Connection String :
    "DSN=xxxxxxxx;UID=LIDDVDP;PWD=********;DATABASE=xxxxxxxx;HOSTNAME=xxxxxxxx;PORT=447;PROTOCOL=TCPIP;SECURITY=SOCKETS;"

    ===============================================================================
    The validation is completed.
    ===============================================================================


    I have a path loop in my Python which I show below that displays all my attempts to get a correct PATH so that Python could duplicate the db2cli validate success but no luck:

    C:\Users\liddvdp\pylib
    C:\Highmarkapps\Python3.12.2
    C:\Highmarkapps\Python3.12.2\Lib\idlelib
    C:\HighmarkApps\Python3.12.2\python312.zip
    C:\HighmarkApps\Python3.12.2\DLLs
    C:\HighmarkApps\Python3.12.2\Lib
    C:\HighmarkApps\Python3.12.2
    C:\HighmarkApps\Python3.12.2\Lib\site-packages
    C:\HighmarkApps\Python3.12.2\Lib\site-packages\clidriver\bin\amd64.VC12.CRT
    C:\HighmarkApps\Python3.12.2\Lib\site-packages\clidriver\bin\icc64
    C:\ProgramData\IBM\DB2\C_Highmarkapps_Python3.12.2_Lib_site-packages_clidriver\cfg
    IBM_DB_HOME


    The error msg never changes, it is:

    Exception: [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 SQLCODE=-1042


    Does anyone have any ideas on corrections are needed ??

    Continue reading...

Compartilhe esta Página