为什么cx_Oracle批量插入在Windows上失败但在Linux上工作?

时间:2018-02-13 23:09:37

标签: python linux windows oracle cx-oracle

我正在使用cx_Oracle executemany()函数以200,000的批量将500,000行插入表中。该功能在RHEL Linux上运行,在Windows 7上失败。无论用户,数据库和表如何,问题都会持续存在。只有在插入超过150,000行时才会出现此问题。请帮助我理解为什么在Windows上失败以及如何解决问题。

Python 3.5

cx_Oracle 5.3

错误消息是ORA-03114:未连接到ORACLE。

代码是

#   Create an Oracle connection
connection = cx_Oracle.connect(user= user, password= pwd, dsn = tns)
#   Create a cursor
cursor = cx_Oracle.Cursor(connection)
try:
    #   Compile the insert SQL w/ bind variable        
    cursor.prepare(insert_sql)
    time.sleep(0.01)
    #   Execute the insert statement, commit & close connection
    cursor.executemany(None, row_batch)
    time.sleep(0.01)
    connection.commit()
    cursor.close()
    connection.close()
    time.sleep(0.01)  
#   In case of error, still close the connection!
#   This avoids a table lock when accessing the table from a different connection
#   at a later date, if this Python session is still active
except Exception as e:        
    cursor.close()
    connection.close()
    raise Exception(e)        

0 个答案:

没有答案