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()
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.