Commit: postgres on cursor and sqlite on connection

Cecil Westerhof Cecil at decebal.nl
Mon Nov 9 10:44:33 EST 2015


I have written some code I like to use with several databases. At the
moment sqlite and postgres. It looks like with progres I can use:
  cursor.execute('COMMIT;')
but that with sqlite I need to use:
    conn.commit()

Is this true, or am I doing something wrong?

When I use
  cursor.execute('COMMIT;')
with sqlite, I get:
    sqlite3.OperationalError: cannot commit - no transaction is active
While
    conn.commit()
does what it should do.

Before I do my statements I use:
  cursor.execute(BEGIN TRANSACTION;')

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list