Search code examples
pythonrcx-oracleroracle

Python cx_Oracle equivalent of ROracle::dbsendquery?


I am using cx-oralce right now and I have to execute a sql statement. For R, sendquery and getinfo are used for it and also to check if the execution is complete or not. Is there something similar in Python that I can do with cx-oralce? I need to be able to see if the execution is complete or not!

rs = ROracle::dbSendQuery(conn, sql)

if (!ROracle::dbGetInfo(rs)$completed) {
    msg <- "Failed "

Solution

  • With cx_Oracle, you would do the following:

    try:
        conn.execute(sql)
    except cx_Oracle.DatabaseError as e:
        print("Failed:", e)