Python Oracle - How to use 2 oracle clients - python

I need to run a django 2.1 project in a server that have an Oracle Client version 10.
But when I try to runserver I get this error:
Oracle client Library must be in version 11.2 or higher
I did some research and the obvious solution was to update the Oracle. But I can't do that because the server runs some applications that only works with Oracle Client 10.
One thing that I tought is to run two Oracle Library Clients. I did some research, one of the answers that I found:
how to set oracle client library path in python when multiple oracle client version installed
But, it's on Linux and I'm on a Windows Server 2012 R2.
How could I run 2 of these Oracle Clients?
Please, could you help me?

Oracle client ver 11.2.0.4 should be able to connect to both 10g and 12c database.
Also check this answer about SQLNET.ALLOWED_LOGON_VERSION parameter.

Related

cx_Oracle.DatabaseError: DPI-1047

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

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.

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.

cx_Oracle. How to access remote machine?

I had a look at cx_Oracle but I have a couple of problems with it. First , my oracle server is on remote machine. Second I do not know on what platform my software will be deployed. All the examples I have founded
like this
http://www.len.ro/2009/08/cx_oracle-on-ubuntu-9-04-jaunty/
or
this https://stackoverflow.com/questions/592/cx-oracle-how-do-i-access-oracle-from-python
assume to have oracle server on the same machine. Is there possibility to have some static compilation so I can easily move my software from one pc to the other?
thx
Of course cx_Oracle can work with server working on other machine. But on client machines you will have to install Oracle client and configure it. I don't know if Oracle client installation can be added to installer of your application. Normally it is huge (600 MiB or so) so it is not a good idea. Then on all client machines you will have to configure Oracle client: set ORACLE_HOME, run Oracle tools to configure connection with database etc.
The only "light" solution I know is to use JDBC from Jython or Java. In this scenario you can use "thin" version of connect string that requires only some .jar libraries. Such connect string looks like:
db = DriverManager.getConnection('jdbc:oracle:thin:169.0.1.225:1521:test_db', 'user', 'passwd')
On client machines it needs ojdbc6.jar and orai18n.jar on CLASSPATH. No installation, no configuration, simple and easy.

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