2010-05-13

how to access Oracle DB using Python in Debian

environment
  • Debian Squeeze (which should be released in a few months).
  • Python 3.1, but I suspect that this should work well with Python 2.6.

installation
  • get registered on Oracle website (pain)
  • download oracle-instantclient11.2-basic*.rpm from Oracle's website (around 40MB worth)
  • convert the rpm to a deb ($ sudo alien oracle-instantclient11.2-basic*.rpm)
  • install the deb to your system ($ sudo dpkg -i oracle-instantclient11.2-basic*.deb)
  • get cx-Oracle rpm for python 3.1, convert it to a deb and install it

setup
  • $ sudo apt-get install libpython3.1 libaio1
  • $ 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

test
If the following executes without printing a message to the screen, the install is most likely successful.
  • $ python3.1 -c "import cx_Oracle"

0 comments:

Post a Comment