ibm_db.connect fails with a catalogued database ( on Windows 10 Workstation )

82 views
Skip to first unread message

namnetes

unread,
Dec 9, 2019, 10:17:17 PM12/9/19
to ibm_db
I installed on my Windows 10 Workstation "IBM Data Server Client Version 11.5" and :
 
  • I Cataloged a DBD0DEF new node:
 
 C:\Program Files\IBM\SQLLIB\BIN>db2 LIST NODE DIRECTORY show detail

 Répertoire des noeuds

 Nombre d'entrées dans le répertoire = 1

 Entrée du noeud 1 :

 Nom du noeud                     = DBD0DEF
 Commentaire                      =
 Type d'entrée du répertoire      = LOCAL
 Protocole                        = TCPIP
 Nom de l'hôte                    = sysibm
 Nom de service                   = 50000
 Nom de l'instance éloignée       = db2inst1
 Système                          = sysibm
 Type de système d'exploitation   = LINUX
 
  • I Cataloged a remote database :
 
 C:\Program Files\IBM\SQLLIB\BIN>db2 LIST DATABASE DIRECTORY

 Répertoire système des bases de données

 Nombre d'entrées dans le répertoire = 1

 Entrée de la base de données 1 :

 Alias de la base de données                        = SAMPLE
 Nom de la base de données                          = SAMPLE
 Nom du noeud                                       = DBD0DEF
 Niveau d'édition de la base de données             = 15.00
 Commentaire                                        =
 Type d'entrée du répertoire                        = Eloigné
 Authentification                                   = SERVER
 Num. de partition de base de données du catalogue  = -1
 Nom d'hôte serveur de remplacement                 =
 Numéro port serveur remplacement                   =
 
  • Testing connection to the remote database cataloged works:
 
 C:\Program Files\IBM\SQLLIB\BIN>db2 connect to SAMPLE user DB2INST1
 Entrez le mot de passe en cours pour DB2INST1 :

   Informations de connexion à la base de données

 Serveur de base de données             = DB2/LINUXX8664 11.5.0.0
 ID utilisateur SQL                     = DB2INST1
 Alias local de la base de données      = SAMPLE
 
 Before all this I install a ibmcom/db2 docker image on a Debian 10 Linux up-to-date (hostname sysibm ipv4 192.168.1.220:50000)
 
  •  Still on the Windows 10 Workstation:
    •  I installed python 3.7.5
    •  I created db2\env environnement ( from db2 folder: python -m venv env )
    •  I installed ibm_db ibm_db_sa : python -m pip install ibm_db_sa
    •  I activated db2\env environnement, I seted IBM_DB_HOME and LIB variables, I started Python Interpreter

C:\Users\ToMe\Development\db2>env\Scripts\activate.bat

(env) C:\Users\ToMe\Development\db2>set IBM_DB_HOME=C:\Users\ToMe\Development\db2\env\Lib\site-packages\clidriver

(env) C:\Users\ToMe\Development\db2>set LIB=%IBM_DB_HOME%\lib

(env) C:\Users\ToMe\Development\db2>python
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>> conn = ibm_db.connect('sample', 'db2inst1', 'db2inst1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: <built-in function connect> returned NULL without setting an erro

  • So the connection fails...
    • I do not know where the mistake is:
      • Did I misconfigure the Python environment ?
      • Did I forget to install a component ?
      • Is my python python wrong ?

I am blocked. Can someone help me please?
thank you in advance

Saba Kauser

unread,
Dec 9, 2019, 10:25:24 PM12/9/19
to ibm_db
As mentioned in another thread, kindly launch python from an admin cmd window and see if the error is gone. Also please share the db2level output. Depending on which client you are using with python driver(the IBM Data Server client or clidriver under sitepackages: based on LIB settting), the client that gets picked up for connection has some differences.
If its the instance based client a.k.a Runtime client, client can read catalogs and hence python driver can connect with the database name, user id and password information. However, if windows is loading the clidriver lib's for ibm_db's connection, then you need to either specify the full connection details in the connection string or in the db2dsdriver.cfg.
You can find more information on this here :

HTH.

namnetes

unread,
Dec 10, 2019, 6:01:31 AM12/10/19
to ibm_db
Hello Saba and thank's for answering

Yes it works with a command prompt with admin privilege.

This is a db2level output from the Windows 10 Workstation where I installed "IBM Data Server Client"

C:\Program Files\IBM\SQLLIB\BIN>db2level db2inst1
DB21085I  Cette instance ou cette installation (le cas échéant, le nom
d'instance : "DB2") utilise la version "64" bits et le code d'édition DB2
"SQL11050" avec l'identificateur de niveau "0601010F".
Les ID des codes d'intégration sont "DB2 v11.5.0.1077", "s1906101300",
"DYN1906101300WIN64" et le Fix Pack est "0".
Le produit est installé sur "C:\PROGRA~1\IBM\SQLLIB" avec le nom de copie DB2
"DB2COPY1".

Sorry the answer is in french and I don't know how to get back to English without uninstalling/reinstalling the product.
 
I am using the clidriver under sitepackages:

Microsoft Windows [version 10.0.18363.476]
(c) 2019 Microsoft Corporation. Tous droits réservés.

C:\WINDOWS\system32>cd \Users\ToMe\Development\db2

C:\Users\ToMe\Development\db2>env\Scripts\activate.bat

(env) C:\Users\ToMe\Development\db2>set IBM_DB_HOME=C:\Users\ToMe\Development\db2\env\Lib\site-packages\clidriver

(env) C:\Users\ToMe\Development\db2>set lib=%IBM_DB_HOME%\lib

(env) C:\Users\ToMe\Development\db2>python
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>> conn = ibm_db.connect('sample', 'db2inst1', 'db2inst1')
>>> print(conn)
<ibm_db.IBM_DBConnection object at 0x000002227464C930>
>>> connState = ibm_db.active(conn)
>>> print(connState)
True
>>>
Reply all
Reply to author
Forward
0 new messages