0

I'm struggling trying to insert a dataframe into a pl/sql table. I can query tables from my own schema w/out issues so the connection is fine. The dataframe shows up fine, but the last line throws me:

DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': ORA-01036: illegal variable name/number

     import os 
     import datetime as dt
     import cx_Oracle
     import sqlalchemy
 
     username = '****'
     password = '****'

     dsn = '(DESCRIPTION=(CONNECT_TIMEOUT=15)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=3)\
       (ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)\
       (SERVICE_NAME=***)))'
     enc = 'utf-8'

connection = cx_Oracle.connect(user=username, password=password, dsn=dsn, encoding=enc)
cursor = connection.cursor()

sessions = glob.glob('path to daily file/*file with timestamp @ end of name*.csv')
latest_sessions = max(sessions, key=os.path.getctime, default = 0)

dfSessions = pd.read_csv(latest_sessions, sep=',', index_col=False, dtype='unicode')
dfSessions.drop([drop several columns], axis=1, inplace=True)

dfSessions.head(5)

dfSessions.to_sql('ARRAY_SESSIONS_NEW', connection,schema='BXP6281', if_exists='replace')
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
BP12
  • 27
  • 6
  • Does this answer your question? ["SELECT name FROM sqlite\_master" error while uploading DataFrame using .to\_sql()](https://stackoverflow.com/questions/69253030/select-name-from-sqlite-master-error-while-uploading-dataframe-using-to-sql) – Gord Thompson Mar 24 '23 at 17:02

1 Answers1

0

You are trying to use bind variables in a places where they are not allowed. Hence the error.

reference: oracle - ORA-01036: illegal variable name/number when running query through C# - Stack Overflow

yang zhou
  • 148
  • 6