Cx_oracle Installation Windows
Honestly it is a hell of a lot easier to install cxOracle from one of the binary installers they have, than from source. HOWTO for.nix: Browse to Instant Client for Linux x86 download page. Welcome to cxOracle’s documentation!¶ cxOracle is a module that enables access to Oracle Database and conforms to the Python database API specification. This module is currently tested against Oracle Client 19, 18, 12, and 11.2, and Python 2.7, 3.5, 3.6 and 3.7. I will cover editing/creating Environment Variables with the later part of this guide because you will have to do it again for cxOracle. Code in Python (you can use an IDE like Eclipse, or a regular text editor like Notepad). Next, run the cxOracle.msi installer for your particular Windows install. Now that was the easy part.
Upon arriving it was hard for Naruto to recognize that it was his village that he was standing in. Animeindo tv naruto vs pain en espanol. This was because Pain/Pein had damage the village almost beyond recognition a few moments before Naruto arrived. Arriving in sage mode, Naruto was able to sense that his teacher kakashi had died.
The Web Server Gateway Interface (WSGI) is a standardized interface between web servers and Python web frameworks or applications. Many frameworks including Django support WSGI.
This post is a brief how-to about configuring Apache's mod_wsgi with Python's cx_Oracle driver for Oracle Database. The steps are for Oracle Linux.
Download Instant Client Basic & SDK ZIP files from OTN. For cx_Oracle 5.1, use the ZIPs, not the RPMs.
As root, unzip the files to the same directory, e.g.
/opt/oracle/instantclient_12_1
:Configure Instant Client:
Install the pip package management tool for Python by following pip.readthedocs.org/en/latest/installing.html and downloading
get-pip.py
. Then run:Install cx_Oracle:
The key here is the use of
LD_RUN_PATH
. This obviates the need to later setLD_LIBRARY_PATH
or configureldconfig
for cx_Oracle to find the Instant Client libraries. There is a cx_Oracle-specific variableFORCE_RPATH
which has the same effect.Note the cx_Oracle installer overloads the meaning of
ORACLE_HOME
. This variable is not normally used with Instant Client.Neither
ORACLE_HOME
orLD_RUN_PATH
need to be set at runtime.If you don't use
LD_RUN_PATH
orFORCE_RPATH
during installation, you will need to makeLD_LIBRARY_PATH
available to the Apache process or useldconfig
to add Instant Client to the system wide library search path.Configuring
ldconfig
is an effective and commonly used solution. However it has a potential problem that if multiple Oracle products exist, with possibly differing versions of Oracle libraries on the same machine, then there might be library clashes. If you wish to use it, create a file/etc/ld.conf.so.d/oracle-instant-client.conf
containing:Then update the linker cache by running:
Alternatively set
LD_LIBRARY_PATH
in Apache's environment file,/etc/sysconfig/httpd
. In Oracle Linux 6 use:In Oracle Linux 7 use:
In Oracle Linux 7, don't reference variables on the right-hand side of the equals sign since they won't be expanded.
[The Apache environment configuration file location varies between Linux distributions. On OpenSUSE see
/etc/sysconfig/apache2
. On Debian-based distributions look at/etc/apache2/envvars
].Set any other Oracle environment variables in the Apache environment configuration file
/etc/sysconfig/httpd
. For example:(Prefix any variable setting with
export
in Oracle Linux 6)Install mod_wsgi:
Add this line to
/etc/httpd/conf/httpd.conf
:On Oracle Linux 6, start the web server with:
On Oracle Linux 7 use:
Create a test file
/var/www/html/wsgi_test.py
that connects to your database:Load
http://localhost/wsgi_test
in a browser. The city of the queried location id will be displayed.
That's it. Let me know how it works for you.
Information on cx_Oracle can be found here.
Information on Oracle Linux can be found here.
Information on Oracle Database can be found here.
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. The cx_Oracle documentation qualifies module interfaces, objects, and connections. 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:
Installation Windows 7 Gratuit
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:
Cx Oracle Documentation
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):
Installation Windows Xp
As always, I hope this helps others who want to work with Python and the Oracle database.