I am unable to run the scrip if I add left JOIN t2 ON Col10 = Col1
as a command in the sql query in Python. Without it I can run the script with no problem.
the error I get is: SQL Error: ORA-00942 table or view does not exist
PS- The script full script is working fine in SQL developer.
Any advise why?
import cx_Oracle
import pandas as pd
conn = cx_Oracle.connect('......')
cur = conn.cursor()
sql = "SELECT \
Col1, \
Col2 \
FROM t1 \
left JOIN t2 ON Col10 = Col1"
cur.execute(sql)
sql_data = pd.DataFrame(cur.fetchall())
col_names = [row[0] for row in cur.description]
sql_data.columns = col_names
sql_data
PS- The full script is working fine in SQL developer.
If that's the case, it means that user - you're connected to in SQL Developer - has access to both t1
and t2
tables.
If Oracle complains that
ORA-00942 table or view does not exist
when you run the same SELECT
statement from Python, it means that user you're connected to now
conn = cx_Oracle.connect('......')
doesn't have the privilege to access the t2
table. That might be because
or some other reason. It is difficult to debug "generic" code you posted as, obviously, tables aren't really t1
nor t2
and columns aren't col1
nor col2
etc. Therefore, re-read what I've just said and try to find the culprit. Good luck!