I'm new to Python, using cx_Oracle.execute to insert a row into a table.
I prepare the insert
statement, which works on SQL developer.
print
statements prior to the execute indicate it hangs on execute.
A simple select
statement works using the same package.
I have tried this on Anaconda as well, same result.
import cx_Oracle
Connection = cx_Oracle.connect('connectioninfo')
cursor = connection.cursor()
print(cx_Oracle.__file__)
print(cx_Oracle._version)
sql1 = "insert into date_dim(dateid) values (20170523)"
print(sql1)
cursor.execute(sql1) # hangs here
count = cursor.rowcount
print(count)
connection.commit() # Never gets to this statement
cursor.close()
connection.close()
cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions. cx_Oracle 8.3 was tested with Python versions 3.6 through 3.10.
cx_Oracle is distributed under an open-source license (the BSD license). A detailed description of cx_Oracle changes can be found in the release notes.
It looks like I had another session open on Sql Developer to test the insert script where I never run a Commit so when I run the Python insert script, somehow it was hanging waiting for the other commit to be issued so it can issue its own commit which was the next line in the code but the other commit was never issued in Sql Developer! As soon as I run a commit in Sql Developer, Python completed the insert. What do you know? Posted my first question on Stackoverflow and my first answer to my first question, that's gotta be a first!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With