Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98540 > unrolled thread

Commit: postgres on cursor and sqlite on connection

Started byCecil Westerhof <Cecil@decebal.nl>
First post2015-11-09 16:44 +0100
Last post2015-11-10 07:53 +0100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Commit: postgres on cursor and sqlite on connection Cecil Westerhof <Cecil@decebal.nl> - 2015-11-09 16:44 +0100
    Re: Commit: postgres on cursor and sqlite on connection Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-09 10:46 -0700
    Re: Commit: postgres on cursor and sqlite on connection dieter <dieter@handshake.de> - 2015-11-10 07:53 +0100

#98540 — Commit: postgres on cursor and sqlite on connection

FromCecil Westerhof <Cecil@decebal.nl>
Date2015-11-09 16:44 +0100
SubjectCommit: postgres on cursor and sqlite on connection
Message-ID<878u675g9q.fsf@Equus.decebal.nl>
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

[toc] | [next] | [standalone]


#98545

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-09 10:46 -0700
Message-ID<mailman.184.1447091232.16136.python-list@python.org>
In reply to#98540
On Mon, Nov 9, 2015 at 8:44 AM, Cecil Westerhof <Cecil@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

[toc] | [prev] | [next] | [standalone]


#98577

Fromdieter <dieter@handshake.de>
Date2015-11-10 07:53 +0100
Message-ID<mailman.199.1447138445.16136.python-list@python.org>
In reply to#98540
Cecil Westerhof <Cecil@decebal.nl> writes:

> 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?

There might be differences between various database interface libraries.
I am using "psycopg" to interface with Postgres - and which it,
you can also use "conn.commit" (as with "sqlite").

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web