psycopg2: connect copy_from and copy_to

Chris cwitts at gmail.com
Tue Feb 19 18:07:47 CET 2008


On Feb 19, 6:23 pm, Thomas Guettler <h... at tbz-pariv.de> wrote:
> > Doesn't PostGres come with Export/Import apps ? That would be easiest
> > (and faster).
>
> Yes, you can use "pg_dump production ... | psql testdb", but
> this can lead to dead locks, if you call this during
> a python script which is in the middle of a transaction. The python
> script locks a table, so that psql can't write to it.
>
> I don't think calling pg_dump and psql/pg_restore is faster.
>
> > prod_cursor.execute('select data from production')
> > for each_record in cursor.fetchall():
> >     dev_cursor.execute('insert into testing')
>
> I know, but COPY is much faster.
>
>  Thomas

I'm used to Oracle which doesn't exhibit this problem... ;)



More information about the Python-list mailing list