Commit: postgres on cursor and sqlite on connection

Ian Kelly ian.g.kelly at gmail.com
Mon Nov 9 12:46:24 EST 2015


On Mon, Nov 9, 2015 at 8:44 AM, Cecil Westerhof <Cecil at decebal.nl> wrote:
> 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;')

This looks like it answers your question:

http://stackoverflow.com/questions/9773200/python-sqlite3-cannot-commit-no-transaction-is-active



More information about the Python-list mailing list