0

I try to write pandas dataframe to Oracle and with to_sql method, sometimes writes successfully and sometimes gives "(cx_Oracle.DatabaseError) ORA-03106: fatal two-task communication protocol error" with same dataframe.

I checked most of the oracle errors for ORA-03106 but could not understand why it is working sometimes and not working for another try.

from sqlalchemy import create_engine


oracle_connection_string = 'oracle+cx_oracle://{username}:{password}@{hostname}: 
{port}/{database}'

engine = create_engine(
    oracle_connection_string.format(
        username= 'user',
        password= 'pass',
        hostname='.....',
        port='..',
        database='sampledb',
    )
)

dataset.to_sql('TEST_TABLE',engine,if_exists='append',index =False)
Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
emreb
  • 1
  • Are you dropping and recreating the table during the execution of the Python process (which is never recommended in Oracle)? It could be the statement cache getting out of sync - you could disable this but it will affect performance, see https://cx-oracle.readthedocs.io/en/latest/search.html?q=stmtcachesize&check_keywords=yes&area=default# – Christopher Jones Jan 05 '20 at 23:31
  • Actually table does not exist in database. I create it from pandas dataframe.Even if it exists, i think to_sql command with 'append' will not drop and recreate the table. – emreb Jan 06 '20 at 05:31

0 Answers0