accessing Oracle DB using Python, in Debian

2011-01-15

The following instructions assume that you are using Debian Squeeze, the current 'stable' release. The instructions here are very specific, so look elsewhere for something more generic.

downloads:

installation and setup:

sudo apt-get install libpython3.1 libaio1 alien
sudo alien --install oracle-instantclient11.2-basic*rpm cx_Oracle*rpm
sudo ln -s /usr/lib/python3.1/site-packages/cx_Oracle.so /usr/lib/python3.1/lib-dynload
sudo ln -s /usr/lib/oracle/11.2/client/lib/libnnz11.so /usr/lib
sudo ln -s /usr/lib/oracle/11.2/client/lib/libclntsh.so.11.1 /usr/lib
echo export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib >> ~/.bashrc
source ~/.bashrc
python3 -c 'import cx_Oracle'

If that last line executes without printing a message to the screen, the install is most likely successful.

For basic usage, see this tiny tutorial.