I have the below code which used to work up until today, basically I am passing bunch of lists to be inserted into database using python.the previous lines before below code takes columns from a pd dataframe and then switches all to a list. then in the following code it inserts them into database. but now it takes long time with no results still. I made few adjustments today but nothing make the code not work. Sometimes I see a tag on the buttom saying "except cx_oracle.databaseerror " but it is still running the code.
# Execute the query
cursor.executemany(query, data)
# Commit the transaction
connection.commit()
print("Data inserted successfully.")
except cx_Oracle.DatabaseError as exc:
error, = exc.args
print("Oracle-Error-Code:", error.code)
print("Oracle-Error-Message:", error.message)
I have the below code which used to work up until today, basically I am passing bunch of lists to be inserted into database using python.the previous lines before below code takes columns from a pd dataframe and then switches all to a list. then in the following code it inserts them into database. but now it takes long time with no results still. I made few adjustments today but nothing make the code not work.
The row that you are trying to modify has probably been UPDATE
d by as earlier session (probably SQL Developer) but that first session has not issued a COMMIT
or ROLLBACK
so the row is locked and the second session is waiting for the lock to be released.
Try running the Python code and if the code is waiting "forever" then go to whichever application has the first session open (maybe SQL Developer or another Python instance that is still running) and run the COMMIT
(or ROLLBACK
) command in that first session and see if the Python code then suddenly completes. If it does then it was waiting for the lock to be released on the row.
If you don't know what session has locked the row then you can try closing everything else and, when the connection is closed, the data will implicitly ROLLBACK
any changes. If this still doesn't work then you can try terminating all the inactive sessions connected to the database (ask your colleagues first just so you don't kill something that someone is actively using).