Reputation: 176
I am writing a Python script to fetch and update some data on a remote oracle database from a Linux server. I would like to know how can I connect to remote oracle database from the server.
Do I necessarily need to have an oracle client installed on my server or any connector can be used for the same?
And also if I use cx_Oracle
module in Python, is there any dependency that has to be fulfilled for making it work?
Upvotes: 1
Views: 6982
Reputation: 61
You have to Install Instance_client for cx_oracle driver to interact with remote oracle server
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html.
Use SQLAlchemy (Object Relational Mapper) to make the connection and interact with Oracle Database.
The below code you can refer for oracle DB connection.
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine('oracle+cx_oracle://test_user:test_user@ORACSG')
session_factory = sessionmaker(bind=engine, autoflush=False)
session = session_factory()
res = session.execute("select * from emp");
print res.fetchall()
Upvotes: 1
Reputation: 6765
Yes, you definitely need to install an Oracle Client, it even says so in cx_oracle readme.txt. Another recommendation you can find there is installing an oracle instant client, which is the minimal installation needed to communicate with Oracle, and is the simplest to use. Other dependencies can usually be found in the readme.txt file, and should be the first place to look for these details.
Upvotes: 0