I am trying to use oracle 12c as database for my application using Django framework. But I am struck in version related issue
Following are the version of library used:
Python 3.6
cx_Oracle 6
Oracle instant client 12.2
Oracle 12 C database on server
Oracle 10 g on local machine where the cx_oracle
is installed
OS is windows 7
Following are the steps which I did to install cx_oracle
pip install cx_Oracle
Download Oracle instant client 12.2 zip file for windows
Extracted the zip file
Added the above unzipped folder to user PATH variable
From CMD I try to execute
python
import cx_Oracle
con = cx_Oracle.connect(uname, pwd, server_ip:port/name)
I am getting the error:
cx_oracle.databaseerror: dpi-1050: oracle client library must be at version 11.2 or higher
Is cx_Oracle having any conflict with oracle 10 g installed at local machine
I cannot upgrade the local oracle 10g db because(no rights given)
How do I resolved the above issue.
How can I make sure cx_Oracle uses the correct Oracle instant client( i.e, 12.2) to connect to server db.
Make sure that the directory containing the instant client is earlier in the PATH environment variable than your 10g installation. That should resolve it for you.
you use set ORACLE_HOME too:
SET ORACLE_HOME=C:\Oracle\client_12_1
SET PATH=C:\Oracle\client_12_1\bin;%PATH%
python
import cx_Oracle
con = cx_Oracle.connect(uname, pwd, server_ip:port/name)
Related
I tried to connect to Sybase database from Django using sqlanydjango, but
I have stuck. One answer saying that
sqlany-django is no longer maintained; it was last updated in May 2016.
What is the other possibility to connect to Sybase database?
OS Ubuntu 18.04
django 2.2.4
Sybase is no longer maintained and it's not supported by Django. I recommend using one of the supported databases:
PostgreSQL
MariaDB
MySQL
Oracle
SQLite
Personally, I would recommend using PostgreSQL - I think it's the most advanced database. If you use it, I would recommend using version 13, since version 14 is still new and I think it's not officially supported by Django yet. It's always a good practice to use the previous major release. Also with Django, I recommend upgrading to the latest major release only about 4 to 6 months after its initial release. So for today, this means using Django 3.2 (latest minor release, currently 3.2.11).
You can use django-environ to define the database you are using in settings.
You could use the freetds module. GitHub repository was active 5 days ago, it aims to provide support for sybase and MSQL Server.
I used it with MSQL
You can download it from there, and installing with the instruction on this link (Sybase python module website)
Then you can test your installation using these steps
You can also try different Django version.
If this doesn't show anything wrong, and Django still won't connect to your DB, you can try to edit Django's source files so the ImproperlyConfigured exception doesn't raise (REALLY REALLY RISKY, DO A BACK UP OF YOUR DB) or migrate your Sybase to a supported database.
You can use pyodbc.
To install this.
Pip install pyodbc
import pyodbc
cnxn = pyodbc.connect(‘DRIVER={Devart ODBC Driver for ASE};Server=myserver;Port=myport;Database=mydatabase;User ID=myuserid;Password=mypassword;String Types=Unicode’)
For reference:-
https://medium.com/#sharma.jayant1992/best-way-to-connect-python-with-sybase-database-76445713efaf
Im a beginner to django.
Someone help to connect Oracle 11g db with django 2.0 in windows. What is the requirements and how to connect and what are the changes to be done.
According to the manual,
Django supports Oracle Database Server versions 12.1 and higher. Version 5.2 or higher of the cx_Oracle Python driver is required.
You may run in to trouble with version 11g -- but if you want to give it a shot, that link has the instructions.
I am facing a problem while installing cx_Oracle module.
I have installed Oracle Sql developer using which I can connect to any Oracle Server. I have also installed cx_oracle module. Now when I try to import the module I am reciving below mentioned error.
import cx_Oracle
Traceback (most recent call last):
File "", line 1, in
import cx_Oracle
ImportError: DLL load failed: The specified module could not be found.
After googling I can find that they want me to install Oracle client, but since I already have Oracle Sql developer which can act as a oracle client, I am unable to find the difference between two. Can someone please help me out.
You will need C-language based Oracle "client" libraries installed on your local machine. (SQL Developer uses Java libraries). To connect to a remote database you can install the Oracle Instant Client.
I have explained installation steps here for 32 bit OS and here for 64 bit OS.
BTW, you have to add your oracle_instant_client path to your PATH environment variable. The error you've got is because the OS did not load required DLL files for oracle.
I have developed a Django application, and i am
trying to get it to run under IIS on Windows Server 2003. I'm
generally following the Django walkthrough but my db is Oracle.
If I run python from the command prompt and import cx_Oracle, it works
just fine. If I run the project with django's development server, everything works fine too.
I haven't managed to get it rum on IIS6 but when a test.py is loaded by IIS and
PyISAPIe, it says it cannot load cx_Oracle and displays the following
error:
Error loading cx_Oracle module: DLL load failed: The specified module
could not be found.
I'm using the 32-bit versions of the following:
Python 2.6.6,
PyISAPIe 1.1.0 rc4 py2.6,
Django 1.4.3,
Oracle Client 11.2,
cx_Oracle 5.1 (for Oracle 11g, Python 2.6)
Any thoughts on why this might be happening?
EDIT:I tried downgrading to cx_Oracle 4.4.1 and now I get the error:
ImportError: cannot import name utils
I am a newbie to Python trying out to quickly build a site using Django.
Following are the steps I have performed (Win 7):
Installed Python 2.7
Installed Django 1.4
Created a project and app
Started the server using 'python manage.py startserver' and accessed using the "http://127.0.0.1:8000" the basic page.
Now wanted to configure my Oracle 11g DB for my project. Hence, installed cx_Oracle 5.1-11g and tried 'python manage.py syncdb' which failed with cx_Oracle.DatabaseError: ORA-24315: illegal attribute type.
Got the same error even from a python interpretor.
import cx_Oracle
connection=cx_Oracle.Connection('python_user','python_user','(DESC..string..)')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-24315: illegal attribute type
I am using the correct credentials and libraries as per my trouble shooting.
Any help is appreciated..
Checking which attribute is failing by raising an explicit exception might help you in the right direction
try:
connection=cx_Oracle.Connection('python_user','python_user','(DESC..string..)')
except cx_Oracle.DatabaseError, e:
print e[0].context
raise
The main problem is versions of the following should be compatible with each other.
Python 2.7, Django 1.4, Oracle DB 11g (which I connect to) and lib cx_Oracle 5.0.3+-11g should be in compatible with Oracle Xe 11.2 (which was 10.2 previously).
After installing the right version and setting the ORACLE_HOME to 'C:/oraclexe/.../11.2.0/server' it started connecting without any issues.