2

I have a requirement to connect oracle DB with python and covert them as Dataframe. Would like to know what are the easy packages available and how to install them ?

I am using Anaconda 3(Python 3.5.2), I tried with cx_oracle but couldn't install because of dependencies. Heard about SQLAlchemy bit not sure how to use it.

3
  • SQLAlchemy doesn't bring its own drivers. You'll still need something like cx_Oracle. Can you expand on this statement: "I tried with cx_oracle but couldn't install because of dependencies"? Fixing those issues is probably the best way to proceed. Commented Feb 19, 2017 at 2:32
  • The exact error which occurs is "ImportError: DLL load failed: %1 is not a valid Win32 application". I have installed pre-compiled version Cx_oracle. Commented Feb 20, 2017 at 3:40
  • At this point I would delete this question and ask a new one about that error. You'll get more eyes on it that way. Commented Feb 20, 2017 at 3:42

2 Answers 2

2

At last it worked after following the below steps,

1.Download and unzip version 12 from http://www.oracle.com/technetwork/topics/winsoft-085727.html. 2.Add "ORACLE_HOME" as a Windows environment variable and set its value to ...\instantclient_12_1, (not its containing folder!). 3.Add this same path to the "Path" environment variable. 4.Only now install cx_Oracle. 5.Reboot the system

Thanks much for everyone!

Sign up to request clarification or add additional context in comments.

Comments

0

I have experience with SQLAlchemy+MySQL.

From the documentation of SQLAlchemy,

engine = create_engine('oracle://username:password@host:port/database') is the connection string.

Where:

username = username

password = password

host = host name/IP e.g.(127.0.0.1)

port = port number

database = database name

engine = create_engine('oracle://username:password@host:port/database')
sql = 'Your SQL query in string.'
df = pd.read_sql(sql,con=engine) 

This should read the sql response into a dataframe.

2 Comments

Tried throws an error "No module named 'cx_Oracle'". As I stated before I coudn't install cx_oracle because of dependencies. Pip install or conda install isn't working out.
@prady, My bad. SQLAlchemy by default is using cx_Oracle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.