Well, the answer should set cx_Oracle, not tx_Oracle. A way to do this in Ubuntu:
sudo apt-get -i alien
- Convert RPM to deb:
sudo alien -d oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
- Install
sudo dpkg -i oracle-instantclient11.2-basic_11.2.0.2.0-2_i386.deb
- Set the ORACLE_HOME environment variable in the /etc/profile.d file by creating the oracle.sh file, which should contain:
export ORACLE_HOME = / usr / lib / oracle / 11.2 / client
source oracle.sh
- Update LD_LIBRARY_PATH:
sudo vi /etc/ld.so.conf.d/oracle.conf which must contain:
"$ ORACLE_HOME / lib"
sudo ldconfig
- Download and install cx_Oracle (depending on the version of the oracle and python you are using) from http://cx-oracle.sourceforge.net/ Convert rpm to deb again using a foreign one and install:
sudo alien -d cx_Oracle-5.1-11g-py32-1.i386.rpm
sudo dpkg -i cx-oracle_5.1-2_i386.deb
- cx_Oracle is installed in / usr / lib / python 2.7 / dist-packages /. You have to do: sudo mv site-packages / cx_Oracle * dist-packages / sudo rmdir site-packages / sudo ln -s dist-packages site-packages
Now you should have no problems connecting to the oracle. From python type:
import cx_Oracle
To connect to the database, specify the connection string in tsnames.ora or directly:
connection_string = 'username / password@ (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 127.0.0.1) (PORT = 1521)) (CONNECT_DATA = (SID = MY_SID)))'
source share