psycopg2 cursor.execute CREATE TABLE issue

Chris Angelico rosuav at
Sun Jan 6 23:19:50 CET 2013

On Mon, Jan 7, 2013 at 9:14 AM, Mitya Sirenef <msirenef at> wrote:
> On Sun 06 Jan 2013 04:53:32 PM EST, andydtaylor at wrote:
>> Wow it's as simple as that! I'm afraid my database experience is in
>> Microsoft Access in Windows and not at the command line, so that wasn't
>> intuitive for me.
> IIRC I made the same mistake when I was using psycopg for the first time.
> I think wrapper libraries like sqlalchemy usually have
> method which is more intuitive.

I recommend getting used to thinking in terms of transactions and
commits. Instead of saving a record, commit a unit of work, which
might involve several changes all at once. A good database (like
PostgreSQL) will guarantee you that either the whole transaction has
happened, or none of it has. And normally, once your commit call has
returned (assuming it doesn't raise an error), you're guaranteed that
the transaction has been completely written to durable storage. Of
course, that depends on *having* durable storage, and many SSDs lie
about what's been written, but that's outside the scope of this post!


More information about the Python-list mailing list