192 DB2 Deployment Guide
You can download the latest source code of IBM_DB driver and IBM_DB_DBI
wrapper from:
http://pypi.python.org/pypi/ibm_db/
If you have downloaded the source code, you can build and install the driver as
well. You can find build instructions in the README file within the compressed
file. Similarly, you can download the latest source code of IBM_DB_SA adaptor
from:
http://pypi.python.org/pypi/ibm_db_sa/
The source can also be browsed online from:
http://code.google.com/p/ibm-db/source/browse
4.6.5 Creating a sample Python application
We have a simple Python application to demonstrate the application deployment.
This sample application named itso_pyapp.py reads the connectivity information
from the command line and uses that to connect to a database. The database
can be both local or remote. If the connection fails, the application gives an
explanatory error message. If the connection succeeds, the application shows
the success message. The complete code is shown in A.4, “Python” on page 264
and is available for download. For the download instructions, refer to AppendixB,
“Additional material” on page267.
To run the application, create a directory and then save the application as
itso_pyapp.py. You can run the application as shown in Example4-32. The
example demonstrates a successful connection to a remote database with the
uncatalog connection. You can also test it against a local database as well.
Example 4-32 Successful connection using itso_pyapp.py
itsouser@ubuntu:~/redbook$ python itso_pyapp.py mensa 50001 test db2inst1
password
Trying to establish connection...
Is connection active? : True
Note: Internet access is required for this method of installation to work. You
can also download the appropriate eggs from:
http://code.google.com/p/ibm-db/downloads/list
Copy these to your system, change to the directory where you have copied
the egg, and issue the following command to install:
easy_install <egg file name>