I have spent almost last 48 hours trying almost all solutions available. My final resort is:
I can access the database through Oracle SQL developer.
Now I want to call the queries in python using pyodbc. But I keep getting this error:
My code looks like this :
import pyodbc
oracledriver = '{xyxzz}'
oracleuid = 'abcd'
oraclepwd = 'abcd'
oracleConn = pyodbc.connect(DRIVER=oracledriver, UID=oracleuid, PWD=oraclepwd, DBQ=oracledbq)
Error :
<i> InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') <i>
I think the problem is with setting up database or something? Please help me with possible issues. Something on the lines of tsanames? (may be)
Edit : When I try to get DSN file :
I get this pop up :
a connection could not be made using the file data source parameters entered
Further info : All the info I have is :
<property name="URL" value="jdbc:oracle:thin:@abcd:1522/abcd" /> <property name="user" value="12345" /> <property name="password" value="12345" />
I started using a different approach using sql alchemy. It looks to be working. But when I try to execute the query, i receive an error. Code and error follows :
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
import cx_Oracle
engine = create_engine('oracle://user:pwdd@localhost:1521/dbname')
connection = engine.connect()
Session = scoped_session(sessionmaker(bind=engine))
s = Session()
result = s.execute('select * from strategy_group_decode;')
The error is :
DatabaseError: (cx_Oracle.DatabaseError) DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\OraHome_2\oci.dll is not the correct architecture". See https://oracle.github.io/odpi/doc/installation.html#windows for help (Background on this error at: http://sqlalche.me/e/4xp6)
Thank you in advance.