Oracle Linux | Thursday, September 28, 2017

cx_Oracle RPMs have landed on Oracle Linux Yum Server

cx_Oracle enables access to Oracle Database from Python and conforms with the Python database API specification. The module works with Oracle Database 11g and 12c and both Python 2.x and 3.x. We have just released the first RPM builds of cx_Oracle on the Oracle Linux yum server, including the latest cx_Oracle 6.0.  You can find them in  the Oracle Linux 7 (x86_64) Development  (ol7_developer) and Oracle Linux 6 (x86_64) Development (ol6_developer)

This post covers the steps to install and set up cx_Oracle 6.0 with the default Python 2.7.5 on Oracle Linux 7.  I used an Oracle Linux 7 Update 4 Vagrant box 
 
1. Download and install Oracle Instant Client 12.2 RPMs

Oracle Instant Client enables development and production deployment of Oracle Database applications. It is used for popular languages and environments including Node.js, PHP, and Python. Download the Instant Client RPM for Oracle Linux x86-64. Install the RPM as root. I’m using yum to resolve any missing dependencies automatically:

$ sudo yum install ./oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:oracle-instantclient12.2-basic-12################################# [100%]

2. Set Library path

Set the environment variable LD_LIBRARY_PATH to the appropriate directory for the Instant Client version. For example:

$ export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib/:$LD_LIBRARY_PATH

Alternatively, if there is no other Oracle software on the machine that will be impacted, permanently add Instant Client to the runtime link path. For example, with sudo or as the root user:

$ sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
$ sudo ldconfig

3. Confirm yum configuration

Make sure you have the ol7_developer repository defined and enabled in your yum configuration. Grab the latest Oracle Linux yum server repo file here http://yum.oracle.com/public-yum-ol7.repo if you need to.

$  grep -i developer\] -A 5 /etc/yum.repos.d/public-yum-ol7.repo 
[ol7_developer]
name=Oracle Linux $releasever Developement Packages ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/developer/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

4. Install cx_Oracle RPM

$ sudo yum install cx_Oracle-py27
...
...
Running transaction
  Installing : cx_Oracle-py27-6.0.2-1.el7.x86_64                                                            1/1 
  Verifying  : cx_Oracle-py27-6.0.2-1.el7.x86_64                                                            1/1 

Installed:
  cx_Oracle-py27.x86_64 0:6.0.2-1.el7   

5. Test connection to Oracle Database 12c

$ python
Python 2.7.5 (default, May 29 2017, 20:42:36) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> db = cx_Oracle.connect("scott/tiger@myhost/sergio")
>>> db.version
'12.2.0.1.0'
>>> 

These new cx_Oracle RPMs offer Python-on-Oracle developers a quick and straightforward way to get started. Give it a try and let us know what you think in the comments or in the Python and Oracle Developer Community

Read on...

In this next post I go into more detail about what the different cx_Oracle RPMs are for and I show how to install our cx_Oracle 6.0 RPM on Oracle Linux 6 to connect Python 3.5 to Oracle Database 12c.

Join the discussion

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
 

Visit the Oracle Blog

 

Contact Us

Oracle

Integrated Cloud Applications & Platform Services