cx_Oracle.DatabaseError: DPI-1047 - python

I am trying to run a code to create tables in oracle database.I am using Python 3.6.5 and Oracle Database 10g Express Edition Release 10.2.0.1.0 in windows 64 bit.
con=cx_Oracle.connect(config.connection)
cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\oraclexe\app\oracle\product\10.2.0\server\bin\oci.dll is not the correct architecture".

Seems like you are unable to connect to the Oracle DB. As pointed out here:
You need to install cx_Oracle extension for python and make sure environment variables are correctly set
In addition, see that the credentials in config.connection are correct.

Update: the latest major release of the cx_Oracle driver doesn't need Oracle libraries by default, so configuration is easier. The driver got renamed to python-oracledb, see the release announcement.
cx_Oracle 6+ needs to be using Oracle 11.2+ libraries. It seems you are linking it with your 10g DB libraries. You can install 11.2 libraries using the free Oracle Instant Client, set PATH to include them, and then connect to your 10g database - but don't stuff up PATH for other applications that need the 10g libraries. You'll probably need to use something like a BAT script to set PATH and then call python.
The Oracle 11.2 libraries must be the same 32-bit or 64-bit as Python is.
If there's anything unclear in https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html then log an issue on the cx_Oracle project at https://github.com/oracle/python-cx_Oracle/issues

Related

Connecting Python 3.x to Oracle DB

I am unable to connect to our enterprise Oracle Db using python 3/cx_Oracle.
Installed are:
python 3 -32 bit
cx_Oracle
Oracle Client 12.1.0.2.0
My connection string attempt is:
import cx_Oracle
conn = cx_Oracle.connect(user='user', password='pwd', dsn='working_dsn')
My PATH variable includes the direct path to my working Oracle library (works using SQL Dev
Error message is:
cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but must be at version 11.2 or higher
I have researched the Orcale installation instructions and have found no way to connect. I have previously tried with no success, had my computer reimaged and Oracle reinstalled to ensure only one version of Oracle and still no success. I need to move from R to Python and this is the last piece I need to make the switch. I am able to connect with R using JDBC driverclass/dbConnect.
If cx_Oracle wont work, is there another option for connecting to Oracle from Python3?
Any thoughts suggestions or places to look? Other connection types used?
Thanks in advance.
pip3 install cx_Oracle
first method:
db = cx_Oracle.connect('root/root#localhost: 1523/orcl')
Second method:
db = cx_Oracle.connect('root/root#localhost: 1523/orcl')
Third method
makedsn(IP/HOST, PORT, TNSNAME)
dsn = cx_Oracle.makedsn('localhost','1523','orcl')
db = cx_Oracle.connect('root','root',dsn)
The error you are getting suggests that you have an older version of the Oracle client installed on your machine. Search the directories of your PATH environment variable for OCI.DLL. If you find an older version you'll need to remove or rename it -- just be aware that whatever application put the file there will stop working!
Another possibility is to go to a command prompt and do the following
PATH=my_path_to_instant_client;%PATH%
python test_connect.py
Finally, make sure that if your Python is 32-bit, so is your instant client installation, and if your Python is 64-bit, make sure that your instant client installation is also 64-bit.

When using cx_Oracle does Oracle need to be installed on all computers with the python application?

I created an exe of my program that communicates with an oracle database using cx_Oracle to create excel sheets. If someone else uses this exe will they need Oracle installed?
Any computer that runs Python programs using cx_Oracle will need an 'Oracle client' installed. This is the set of Oracle libraries needed by cx_Oracle that allow connections to a database. The database can be on a remote computer. The Oracle client libraries are available in three different installs:
With the Oracle Database install
With a 'full' Oracle Client install
From Oracle Instant Client
The most common in your case would be to use Oracle Instant Client, which is relatively small and is simple to install.
You download the Instant Client 'Basic' package matching your operating system and the Python architecture (32 or 64 bit). Unzip it. Set your operating system search path such as PATH (on Windows) or LD_LIBRARY_PATH or ldconfig (on Linux) to the directory you unzipped.
Instant Client Downloads and instructions are at https://www.oracle.com/database/technologies/instant-client.html
cx_Oracle installation instructions are at https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html

How can I connect with an Oracle 8i database through a Python 3.6 code?

I wanna connect to Oracle 8i Database using Python2.7 or Python3.6 as I am not an Oracle guy so I need your help on this.
I am having following scenario:
My Database server is located at remote location.
I have to connect with that database through either version of Python2.7 or Python3.6.
After connection I just wants to do as normal queries.
Things which I have already done is:
cx_Oracle library 6.2 version installed.
Oracle instant Client libraries installed and using these libraries I am able to connect from Oracle 9i to Oracle 12c.
Now I just wants to make connection with Oracle 8i database.
thank you.
Uh, Oracle 8 ... where did you manage to find that fossil?
Anyway: this page says that you should use "OJDBC and JayDeBeApi" which works with databases
supported by Oracle's JDBC drivers (currently 8.1.7 to 11.2.0.2.0)
There's some more info, so - have a look.

DLL file load failed For Cx_oracle

I'm using Python 3.1.2. I've downloaded cx_Oracle (Windows x86 Installer (Oracle 10g, Python 3.1)). I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64-bit.
I'm trying to access a remote Oracle server. I haven't installed any Oracle client. However, I use SQLTools 1.5.0, which I manually copy-pasted from some place.
I came to know cx_Oracle needs a DLL file from an Oracle client to access a remote database, so I copied all the DLL files from the folder of SQLTools to a location. I added the location where I kept the ora.dll into the system's environment variable (PATH and ORACLE_HOME). But it doesn't seem to work. I get the same error:
ImportError: DLL load failed: The specified module could not be found.
I'm missing something. Will this manual work do the job or do I have to install an Oracle client?
The Oracle client isn't an installer, but a series of zip packages. Download the appropriate Instant Client from this here (http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html), unzip them, stick them on your C drive or anywhere you prefer, and add it to your LD_LIBRARY_PATH and ORACLE_HOME env vars.

cx_oracle and oracle 7?

At work we have Oracle 7. I would like to use python to access the DB.
Has anyone done that or knows how to do it?
I have Windows XP, Python 2.6 and the cx_oracle version for python 2.6
However, when I try to import cx_oracle i get the following error:
ImportError: DLL load failed the module could not be found
Any help is appreciated!
Matt
cx_Oracle is currently only being provided with linkage to the 9i, 10g, and 11i clients. Install one of these clients and configure it to connect to the Oracle 7 database using the proper ORACLE_SID.
Make sure you have the location of the oracle .dll (o files set in your PATH environment variable. The location containing oci.dll should suffice.
I was running into that same problem at work. I finally dropped trying to use cx_Oracle and went with adodbapi. It worked with Oracle 8.
If you have ODBC configured then you can use it. It is available with ActivePython or as win32 extensions. You will obtain connection with:
connection = odbc.odbc('db_alias/user/passwd')
Optionally you can use Jython and thin JDBC client. Instalation of client is not required. With Jython you have access to db via db url:
db = DriverManager.getConnection(db_url, usr, passwd)
where db_url looks like:
jdbc:oracle:thin:user/passwd#machine_ip:port:dbname

Categories