0

when I check this question, I don't understand why the solution is not working for me. I run the following code:

query = """SELECT* 
           FROM TRANSACTION
           """
df_ora = pd.read_sql(query, con=connection)

and get the error: DatabaseError: ORA-00942: table or view does not exist

The database is organized in shemes, where Datenbasis is one scheme. So it looks like the following: Database ---> Datenbasis -> Table --> TRANSACTION

what do I miss here, what do I have to specify?

I am connection as following:

db_connection_string = 'User/pw@server:port/Name'
con = cx_Oracle.connect(db_connection_string)
PV8
  • 5,799
  • 7
  • 43
  • 87

3 Answers3

0

The error is clear:

1.The user you are connecting with has no privileges over the table. 2.The table does not exist at all.

db_connection_string = 'User/pw@server:port/Name'

You have to ask your DBA to grant select over the table to your user.

Besides, you would have to change:

query = """SELECT* 
           FROM TRANSACTION
           """
df_ora = pd.read_sql(query, con=connection)

for

query = """SELECT* 
           FROM SCHEMA_OWNER.TRANSACTION
           """
df_ora = pd.read_sql(query, con=connection)

Where schema_owner is the schema which owns the table. If you don't want to change this last part, you would need to create a synonym.

Roberto Hernandez
  • 8,231
  • 3
  • 14
  • 43
0

The answer is to pick the right schema with the curser, the working code looks like:

db_connection_string = 'User/pw@server:port/Name'
con = cx_Oracle.connect(db_connection_string)
con.current_schema = 'DATENBASIS'
query = """SELECT* 
           FROM TRANSACTION
           """
df_ora = pd.read_sql(query, con=connection)
PV8
  • 5,799
  • 7
  • 43
  • 87
0

check if you can select from the table in SQL plus/ SQL developer, if not then the user id that you are using to connect to the DB does not have access to that table.

SELECT * FROM Datenbasis.TRANSACTION;

Himanshu Kandpal
  • 1,261
  • 8
  • 11