If you plan on writing any python applications/scripts for performing any basic SQL query’s against an oracle database you will need to have the cx_oracle library files installed to your machine (or server) here are some quick instructions on how to install them.
Please be aware i have only tested these instructions under Ubuntu 10.10 (32bit) using the 11.2 oracle instant client, when I have time I will try and install this on one of the x86_64 machines i have access to.
1. become root user
1 | sudo su - |
2. install python-setuptools python-dev needed for the easy_install later on.
1 | apt-get install python-setuptools python-dev |
3. install the following from the oracle website http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
* instantclient-basic-linux (32bit or 64bit depending on your system)
* instantclient-sdk-linux (32bit or 64bit depending on your system)
I have installed the files to /opt/instantclient_11_2 for ease
3. Setup ORACLE_HOME and LD_LIBRARY_PATH e.g.
* instantclient-basic-linux (32bit or 64bit depending on your system)
* instantclient-sdk-linux (32bit or 64bit depending on your system)
I have installed the files to /opt/instantclient_11_2 for ease
3. Setup ORACLE_HOME and LD_LIBRARY_PATH e.g.
mkdir /opt/instantclient_11_2
1 | export ORACLE_HOME=/opt/instantclient_11_2 |
2 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME |
4. The cx_oracle file needs to find a certain library file libclntsh.so you will find this under /opt/instantclient_11_2/libclntsh.so.X.X (X = version number) please make a symlink as follows
1 | cd $ORACLE_HOME |
2 | ln -s libclntsh.so.11.1 libclntsh.so |
5. run the following from the command line as root
1 | easy_install cx_oracle |
6. job done.
Here is a good tutoral on how to use the library files once you have things installed
No comments:
Post a Comment