I have tried connecting exadata from python using cx_Oracle, but faced issue stating
cx_Oracle.DatabaseError: DPI - 1047: Cannot locate a 64bit Oracle client library.
I am trying to install a 64bit cx_Oracle, but I need to know can I connect from python to exadata.
Follow the cx_Oracle Linux installation instructions. The piece you are missing is access to Oracle Client libraries. As noted in the other answer, using Instant Client is the way to go. You'll need the "Basic" or "Basic Light" package for Linux x86-64. If you don't know your character set requirement, then use "Basic". You can use the latest 19c version. This will let you connect to Oracle DB 11.2 and newer.
If you have root access (?) you may find the RPM packages easier. If you want to use ZIP files, unzip the package, set your LD_LIBRARY_PATH environment variable to the directory, and run Python.
In your cx_Oracle scripts you use the same database credentials and connection string that you would use in SQL*Plus.
Welcome to Stack Overflow!
For the record, Oracle Exadata is a platform consisting of hardware and software designed for extreme Oracle Database performance. cx_Oracle is the Python client library to operate on an Oracle Database - hence you want to connect to an Oracle Database utilizing the Python programming language.
cx_Oracle depends on OCI (Oracle Call Interface). You need to download and install Oracle Client Library on your workstation before you can do import cx_Oracle from within Python.
You will find the Oracle Client Library here
Best of luck!
Related
I need to query SQL Server from Python in a machine that I don't have admin rights. I can't install drivers in it. I'll query mainly from a Linux machine, but it would be nice if I it can also be used from Windows during development.
I want to make a simple query in MS SQL Server with a Python lib. A lib that doesn't need any driver installed in the Operating System. Is it possible? Everything that I found asks to install the Microsoft driver in the host OS.
A quick search turns up pydts but it's not supported by Microsoft and I have no idea how widely adopted it is or if it's being actively maintained. Here's the GitHub repo.
I'm trying to follow this tutorial to connect django with a legacy oracle database a little confused what to put in the Name. In addition, I'm a little confused how to install the Instant Client so that my django/python application will be able to see the instant client.
I'm on Windows 10, django 3.0.1, python 3.8
1.) First of all, when I connect to the database with the enterprise manager, I see this (edited):
So when I fill in my django, this is what I put(edited):
in the Name, am I suppose to put ServerName (following the enterprise manager image) or do I put servername/schema that I'm trying to connect to?
2.) I contacted the admin, and the Oracle database is 11g, and also in Visual Studio, I connected to the database and checked the version, it is
So I download the instant client for 11.2.0.4.0 (32 bit)
I use 32bit because I think my python is 32 bit.
Unzipped it into C:\instantclient_11_2
Added C:\instantclient_11_2 to my System Environment Variables, in the PATH
And tried to run the following
And I receive the error:
But according to the documentation here, I need to set it to lib_dir, but I'm not sure where the lib_dir variable is? is this an environment variable? Or something in my application? Settings.py?
In your case, I would use an Oracle client 18c or 19c . Both can connect to a 11g database without any issue.
Using 11g version with cx_Oracle 8.0 might lead to issues.
I'm quite new to Python and programming in general, so please bear with me. At my work I have Anaconda (Python vers 2.7) installed and would like to connect to a Microsoft SQL Server database, preferably with ODBC. Related to this task I have a number of questions:
Is it correct that I cannot connect to a SQL Server database using sqlite3 or sqlalchemy? That I need a module like pyodbc? A brief explanation of why this is the case would be much appreciated.
EDIT: Question related to installation of pyodbc in anaconda removed, since I figured this out (by reading Cannot Install Python Modules after Installing Anaconda)
Help is much appreciated! If any of my questions/any other specifics need to be cleared up, please don't hesitate to ask. Thanks
I do not use Anaconda, but I use various databases and ODBC. At first you can try if you have odbc module installed. It is a part of pywin32 package (http://sourceforge.net/projects/pywin32/files/) and is packed with ActiveState Python distribution. Other distribution can install it separately. Simply try:
import odbc
db = odbc.odbc('dsn/user/password')
You can also try with pyodbc you mentioned in question. There is precompiled version for Windows and I think it will work with your Anaconda environment. After installing try:
import pyodbc
db = pyodbc.connect('Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;')
You can find more connection strings at http://www.connectionstrings.com/
EDIT:
It seems that you have problem with bitness of ODBC driver.
Try to run this program to see what sources are visible to ODBC manager:
import odbc
source = odbc.SQLDataSources(odbc.SQL_FETCH_FIRST)
while source:
print(source)
source = odbc.SQLDataSources(odbc.SQL_FETCH_NEXT)
I have two RHEL servers running Python 2.4 and 2.6 separately. There is an Oracle database on the other server I need to access.
I was trying to install cx_oracle on my RHEL server but found out that the Oracle client must be installed first.
The problem is, I don’t have permission to install Oracle's client on both RHEL servers. On the same servers, a Perl program can connect to the Oracle db using:
DBI->connect("dbi:Oracle:host=myhost.prod.com;sid=prddb",'username','password')
Can Python do the same without installing cx_oracle and the Oracle client? Or are there any suggestions about how to write a module myself to do the same thing?
Thanks in advance!
An excerpt from https://forum.omz-software.com/topic/184/oracle-database:
There's no pure python client for Oracle and likely never will be. Even wonderful third-party toolsets like SQLalchemy still rely on cx_Oracle underneath to do the actual communication to the Oracle database servers.
—also, deciding by Google, the answer is no: there do not seem to be any pure Python Oracle clients in existence as of today.
Usually, all you need are the libraries, which don't necessarily require sudo rights. Extract them to a place the software will be able to read from and set the following environment variables accordingly:
ORACLE_HOME=path/to/where/you/extracted/libs
TNS_ADMIN=path/to/tnsnames.ora
I have had best luck skipping tnsnames, and just specifying the host, port, etc in the connection, but it's quite possible you'll need it for cx_oracle...I don't remember from when I used it ages ago.
if you don't want use cx_Oracle you should use expect scripting. ( for python pexpect). But you need to be carefully for handle all expectations.
I have a Firebird DB set up on my computer and I want to be able to retrieve data from a different computer. What is the best way to go about this?
I am running windows and using python.
Install firebird client to the client pc
To connect firebird programmaticaly from python you should install a python Firebird driver.
For Python 2.x, you can use kinterbasdb. This is the legacy driver and I think it is not actively developed but only maintained.
To connect windows based server database from kinterbasdb you can use
Import kinterbasdb as k
k.init(type_conv = 300) #
con = k.connect(dsn='127.0.0.1:c:\\db\\test.fdb', user='sysdba', password='masterkey', charset='YOUR_CHARSET', dialect=3)
Of course you should adjust connection parameters according to your system. Kinterbasdb documentation is here
If you want use an ORM, you can use SqlAlchemy which uses kinterbasdb for Firebird Support
For Python 3k you can use pyfirebirdsql which also supports Python 2.5+ and under active development, but not supported by SqlAlchemy yet.
Run Firebird server on the computer with database file and connect to it from remote computer. You will need in Firebird client library installed on remote computer.
I think we need a bit more info.
Do you want database access - as in "I want to be able to edit table layout and define new tables, views, procedures and so on" ?
Or do you only need to get data from the database using python ?
The latter could be achieved by installing a Firebird client (in essence its a dll (fbclient.dll)) and then use a connect string from python to connect to your database.