2016-10-19

This shows you how to install the cx_Oracle library for Python 2.7 on Fedora Linux. If Fedora has it on the server you can download it with the following yum command:

Currently, you’ll get the following failure because it’s not available in the Fedora repository:

You can download the cx_Oracle library from the Python web site. Assuming your Linux user’s name is student, you download the cx_Oracle library into the /home/student/Downloads directory. Then, you use the su or sudo command to become the root user.

As the root user, run the following yum command:

You should see the following output:

After you install the cx_Oracle-5.2.1-1.x86_64 package, you can find the installed files with this rpm command:

It lists:

After you installed the software, you can test whether inside Python’s IDLE environment with the import command, like this:

This error indicates that Oracle Client software isn’t installed, which is true in this case. I only installed the Oracle Database 11g Express Edition. You need to download the Oracle Client software and install it as the root user.

You download the Oracle Client software from the Oracle web site. Assuming your Linux user’s name is student, you download the cx_Oracle library into the /home/student/Downloads directory. Then, you use the su or sudo command to become the root user.

As the root user, run the following yum command:

You should see the following output:

You can create a Python program that checks your ability to connect to the Oracle database, like the following oracleConnection.py file:

You can run this from the Linux command line with the following syntax:

It should return the following string:

Now, you can create a Python program that reads data from the Oracle database. The following oracleString.py file reads a string literal from the pseudo table dual:

You can run this from the Linux command line with the following syntax:

It should return the following string:

Now, you can create a Python program that reads actual table data from the Oracle database (assuming you have a copy of my video store database). The following oracleTable.py file reads a string literal from the pseudo table dual:

You can run this from the Linux command line with the following syntax:

It should return the following strings (only a subset of the returned values):

As always, I hope this helps others who want to work with Python and the Oracle database.

Show more