I'm brand new to SA, and trying to import data from a text file by
directly executing postgresql's COPY statement. It works fine in the
postgresql client (psql), but when I run the same statements through
SA I get an empty table. This is a snip of the python code:

dbengine = create_engine('postgres://%s:[EMAIL PROTECTED]:5432/database' %
(admin, passwd))
dbengine.echo = True
dbconn = dbengine.connect()
dbconn.execute("DELETE FROM facility")
dbconn.execute("COPY facility FROM '" + abspath(output_file) + "' WITH
DELIMITER '|' NULL ''")
dbconn.close()

This is the echo text, which looks fine to me:

2008-05-22 20:14:46,726 INFO sqlalchemy.engine.base.Engine.0x..cL
DELETE FROM facility
2008-05-22 20:14:46,727 INFO sqlalchemy.engine.base.Engine.0x..cL {}
2008-05-22 20:14:46,746 INFO sqlalchemy.engine.base.Engine.0x..cL
COMMIT
2008-05-22 20:14:46,748 INFO sqlalchemy.engine.base.Engine.0x..cL COPY
facility FROM '/home/brad/facility.cln' WITH DELIMITER '|' NULL ''
2008-05-22 20:14:46,748 INFO sqlalchemy.engine.base.Engine.0x..cL {}

The DELETE statement clearly works since at this point my table has 0
rows. I know pgsql is doing something with the file because if there
is an error in the data I get an exception. And if I run the same
statements under the same user account in psql, it results in 39543
rows. Maybe SA is putting second execute in a transaction that isn't
being commited?

>>> sqlalchemy.__version__
'0.4.2p3'

$ psql --version
psql (PostgreSQL) 8.3.1

$ uname -a
Linux name 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686
GNU/Linux

Thanks for any pointers.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to