Closing connection...

Connection closed.

If there is any incorrect information, the connection will fail and an error message is returned as shown in Example 4-33.

Example 4-33 Failed connection using itso_pyapp.py

itsouser@ubuntu:~/redbook$ python itso_pyapp.py mensa 50001 test db2inst1 wrongpassword

Trying to establish connection...

Traceback (most recent call last):

File "itso_pyapp.py", line 38, in <module> main(sys.argv[1:])

File "itso_pyapp.py", line 31, in main conn = ibm_db.connect( dsn, "", "" )

Exception: [IBM][CLI Driver] SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001 SQLCODE=-30082

We now introduce deployment considerations.

4.6.6 Deploying a Python application with the DB2 drivers

In this section, we demonstrate how to deploy a DB2 Python application with DB2 drivers. We assume that the target system already has the Python installed but the DB2 driver for Ruby application is not on the system. The steps for deploying a Python application with ODBC CLI driver are as follows:

￿Prepare the Python driver file and redistributable DB2 driver files

￿Prepare the Python application package

￿Prepare the deployment package

￿Deploying the deployment package to the target system

We organize all the deployment files under a directory, python_deploy.

Preparing Python driver and redistributable DB2 driver files

If your application is using only the IBM_DB driver, then it is not necessary to package IBM_DB_SA as well. Similarly, you do not have to set up PYTHONPATH for the IBM_DB_DBI wrapper if your application is not using it.

You can obtain the driver egg file from any of the methods described in “Installation procedure” on page 191. For this example, we have built the driver egg file from source code named ibm_db-0.2.9-py2.5-linux-x86_64.egg and the setup tools from the Internet named setuptools-0.6c7-py2.5.egg.

Chapter 4. Deploying applications with DB2 193

Page 207
Image 207
IBM manual Deploying a Python application with the DB2 drivers, Example 4-33 Failed connection using itsopyapp.py