[sqlalchemy] Postgresql COPY

2011-04-15 Thread Yang Zhang
Is it possible to execute a Postegresql COPY ... FROM STDIN statement
via sqlalchemy, or do we have to drop down to psycopg2 for that
(http://initd.org/psycopg/docs/usage.html#using-copy-to-and-copy-from)?
 Tried executing a COPY statement followed directly by the input
values, as in psql, but that didn't work.  Thanks in advance.

-- 
Yang Zhang
http://yz.mit.edu/

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Postgresql COPY

2011-04-15 Thread Michael Bayer

On Apr 15, 2011, at 3:17 AM, Yang Zhang wrote:

 Is it possible to execute a Postegresql COPY ... FROM STDIN statement
 via sqlalchemy, or do we have to drop down to psycopg2 for that
 (http://initd.org/psycopg/docs/usage.html#using-copy-to-and-copy-from)?
 Tried executing a COPY statement followed directly by the input
 values, as in psql, but that didn't work.  Thanks in advance.

SQLAlchemy doesn't have functions that connect to psycopg2's copy_from() etc. 
methods and from psycopg2s docs it seems this is how those functions are 
usable, as opposed to emitting the word COPY.   So you know as much as I do 
here, and you likely have to use the psycopg2 connection.you can get one 
from the pool via engine.raw_connection() if you wanted.

 
 -- 
 Yang Zhang
 http://yz.mit.edu/
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Postgresql COPY

2011-04-15 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il 15/04/2011 09:17, Yang Zhang ha scritto:
 Is it possible to execute a Postegresql COPY ... FROM STDIN statement
 via sqlalchemy, or do we have to drop down to psycopg2 for that
 (http://initd.org/psycopg/docs/usage.html#using-copy-to-and-copy-from)?
  Tried executing a COPY statement followed directly by the input
 values, as in psql, but that didn't work.  Thanks in advance.
 

The problem is that psycopg2, if I'm not wrong, only supports an high
level interface to COPY command.
With plain libpq, you can issue a normal query string with the COPY
command, and then use PQputCopyData and PQputCopyEnd functions to send data.

psycopg2, instead, implements custom methods for copy support (I assume
this is done to avoid having to handle/expose the additional
PGRES_COPY_OUT or PGRES_COPY_IN status code, and an additional
PGRES_COMMAND_OK after PQputCopyEnd).



Regards   Manlio
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2odH0ACgkQscQJ24LbaURe/gCgmptRuAv1usFDYIzChjUIDt/1
bdwAnjLUij/CFScNEv1zV/K/Y//v9Akf
=Sxsi
-END PGP SIGNATURE-

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.