psycopg2: connect copy_from and copy_to
hv at tbz-pariv.de
Tue Feb 19 17:23:19 CET 2008
> 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.
More information about the Python-list