Re: [cx-oracle-users] cursor.execute() then conn.commit however SQL update not committed in databas
Brought to you by:
atuining
From: Wong W. Meng-R. <r3...@fr...> - 2011-10-13 11:42:16
|
Hi Anthony, Yes I realized now that the SQL update actually failed, as now cx_Oracle doesn't return the number of row affected from INSERT/UDPATE/DELETE compared to oracledb so I overlooked it. Today I printout the cursor.rowcount to confirm that. It is true what you were saying. Yeah so likely this could be the rootcause and not that my API doesn't use the same connection object throughout like it did in the same framework using Queue and condition stuffs for mutex control in a multi-threaded environment. My application utilizes parameters in sequence object a lot in cursor.execution(). The order of the parameters and values is different in cx_Oracle as compared to oracledb so many API failed. So I am planning to write a parser or wrapper to handle this instead of letting the application team to modify at their API level, hiding this difference to lessen the efforts in migrations from python 1.5.2 to 2.7.1. Thanks for your reply and I will revert to this one more time when I have confirmed the threading mechanism from my old RMI architecture still works correctly, after experimenting it a working API. Regards, Wah Meng -----Original Message----- From: Anthony Tuininga [mailto:ant...@gm...] Sent: Thursday, October 13, 2011 11:51 AM To: cx-...@li... Subject: Re: [cx-oracle-users] cursor.execute() then conn.commit however SQL update not committed in database Hi, Check how many rows were updated by looking at cursor.rowcount. At a guess you are using a CHAR column instead of a VARCHAR2 column and they behave differently. :-) Anthony On Sun, Oct 9, 2011 at 5:42 AM, Wong Wah Meng-R32813 <r3...@fr...> wrote: > Hello there, > > > > I continue to work on my application migration from python 1.5.2 to 2.7.1, > from using oracledb to cx_Oracle in a python RMI framework. > > > > I am troubleshooting this issue whereby my API is updating userLastName of a > given userId. I am doing cursor.execute("update..") first then > connection.commit(). However, the data in the database doesn't seem changed, > which means the "commit" did not get through. There is no error generated > when ".commit()" is executed though. > > > > I am thinking my API might be using different connection objects to do the > cursor.execute() and connection.commit(), respectively however the > likelihood is low, as the old code using oracledb was working well. > > > > Does anyone has any idea how this can happen? > > > > > > Source code... > > > > def _processDB( self, conn_type, conn, cursor, db_type, db_msg ): > > """Internal method to execute the database transaction given.""" > > > > reply_error = None > > try: > > print ">>>> _processDB : conn_type=%s, db_type=%s, > db_msg=%s"%(conn_type, db_type, db_msg) > > if db_type == STMT_EXEC: > > msg, arg = db_msg > > if arg: > > reply_value = cursor.execute( msg, arg ) > > else: > > reply_value = cursor.execute( msg ) > > if reply_value == None: # none-select statement > > if conn_type == GENERAL_CONN: > > conn.commit() > > else: > > reply_value = cursor.fetchall() > > > > elif db_type == STMT_EXECL: > > msg, arg = db_msg > > if arg: > > reply_value = cursor.execute( msg, arg ) > > else: > > reply_value = cursor.execute( msg ) > > if reply_value == None: # select statement > > reply_value = cursor.fetchall() > > # get description > > desc_list = cursor.description > > desc = [] > > for i in desc_list: > > desc.append( i[0] ) > > reply_value.insert( 0, tuple(desc) ) > > else: > > if conn_type == GENERAL_CONN: > > conn.commit() > > > > elif db_type == STMT_PROC: > > reply_value = conn.callproc( db_msg ) > > > > elif db_type == STMT_COMMIT: > > print "Hello world" > > reply_value = conn.commit() > > > > elif db_type == STMT_ROLLBACK: > > reply_value = conn.rollback() > > > > > > print ">>>> _processDB : reply_value = %s"%(reply_value,) > > > > > > Debug Printout > > > >>>>> _processDB : conn_type=1, db_type=exec, db_msg=('select sysdate from >>>>> sys.dual', ()) > >>>>> _processDB : reply_value = [(datetime.datetime(2011, 10, 9, 19, 25, >>>>> 39),)] > >>>>> _processDB : conn_type=1, db_type=exec, db_msg=("select 1 from USERS >>>>> where USER_ID = 'ftcs' and ROWNUM = 1", ()) > >>>>> _processDB : reply_value = [(1,)] > >>>>> _processDB : conn_type=1, db_type=exec, db_msg=('update USERS set >>>>> USER_MODIFY_USER = :2, USER_MODIFY_DATE = :3, USER_FIRST_NAME = :4 where >>>>> USER_ID = :1', ['ftcs', 'ftcs', datetime.datetime(2011, 10, 9, 19, 25, 39), >>>>> 'Steven II']) > >>>>> _processDB : reply_value = None > >>>>> _processDB : conn_type=1, db_type=commit, db_msg=commit > > Hello world > >>>>> _processDB : reply_value = None > > > > > > Regards, > > Wah Meng > > Genesis Wafermap Support Ticket: > > To report a problem: > http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820 > > To request a service: > http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819 > > Or if it is related to EWM or DSA: > http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539 > > > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2dcopy2 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |