Oct
29
2009

Oracle, Python, and Red Hat Enterprise Linux 4 using cx_Oracle

After a bunch of trial and error, the following packages are needed to Install cx_Oracle for Python and the required Oracle Instant Client for Red Hat Enterprise Linux 4. Its not that this is too difficult, its that RHEL4 is old. Getting the two to place nice took a sec to figure out. This will install cx_Oracle for python that comes with RHEL4, which as of this writing is Python version 2.3.4 for Red Hat Enterprise Linux AS release 4 (Nahant Update 8). I am sure you can use the newer libraries with the a new install of Python, but I wanted to stay as close as possible to the versions supported by Red Hat. For better for worse! ;-)

1. Download the cx_Oracle library.
wget http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-4.3.1-10g-py23-1.i386.rpm?download

2. Install cx_Oracle
rpm -i cx_Oracle-4.3.1-10g-py23-1.i386.rpm

3. Download Oracle Instant Client from the URL below. Must be logged in so do this from a browser.

http://download.oracle.com/otn/linux/instantclient/10204/oracle-instantclient-basiclite-10.2.0.4-1.i386.rpm

4. Install Oracle Instant Client
rpm -i oracle-instantclient-basic-10.2.0.4-1.i386.rpm

5. Add the path to the instant client libs to LD_LIBRARY_PATH.
echo “export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client/lib/:\$LD_LIBRARY_PATH” >> /etc/profile

Thats it! Want to be sure?

[xyz@pdq ~]$ python2
Python 2.3.4 (#1, Jul 16 2009, 07:01:37)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> oraConn=cx_Oracle.Connection("username/password@server/SqlNetAlias")
>>> curs = oraConn.cursor()
>>> curs.execute("select 1 from dual")
[]
>>> rows = curs.fetchmany(curs.arraysize)
>>> for row in rows:
... print row[0]
...
1
>>> oraConn.close()
>>>

The more I learn about cx_Oracle and Python I will try to update this space. All I know right now is that it is FAST!

VN:F [1.9.3_1094]
Rating: 5.5/10 (2 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
Oracle, Python, and Red Hat Enterprise Linux 4 using cx_Oracle, 5.5 out of 10 based on 2 ratings

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes