Why the need to commit explicitly when doing an UPDATE?

前端 未结 3 2170
迷失自我
迷失自我 2020-12-03 21:50

Here\'s my code:

import cx_Oracle

conn = cx_Oracle.connect(usr, pwd, url)
cursor = conn.cursor()
cursor.execute(\"UPDATE SO SET STATUS=\'PE\' WHERE ID=\'100         


        
3条回答
  •  温柔的废话
    2020-12-03 22:08

    The DB-API spec requires that connecting to the database begins a new transaction, by default. You must commit to confirm any changes you make, or rollback to discard them.

    Note that if the database supports an auto-commit feature, this must be initially off.

    Pure SELECT statements, since they never make any changes to the database, don't have to have their changes committed.

提交回复
热议问题