From: | Kynn Jones <kynnjo(at)gmail(dot)com> |
---|---|
To: | pgsql-general General <pgsql-general(at)postgresql(dot)org> |
Subject: | How to send multiple SQL commands from Python? |
Date: | 2009-10-10 19:09:29 |
Message-ID: | c2350ba40910101209g51286fffv2fcf6309793fdeda@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am porting some code from Perl to Python; in the Perl original I use
either DBI::do or a rickety home-built module to pass multiple SQL
statements (as one single block of SQL) to the Pg server. The typical usage
is something like this:
$dbh->do( <<EOSQL );
ALTER TABLE $xn OWNER TO xdev;
GRANT ALL ON TABLE $xn TO xdev;
REVOKE ALL ON TABLE $xn FROM PUBLIC;
GRANT SELECT ON TABLE $xn TO PUBLIC;
EOSQL
How can I do this sort of thing from Python?
I've looked into the docs for psycopg2, but I can't find anything like the
do command used above. Did I overlook it? If not, what can I use instead?
I'm not wedded to psycopg2, in fact its lack of documentation worries me; if
there's a better alternative that I can use from Python please let me know.
TIA!
kynn
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Ribe | 2009-10-10 19:22:19 | Re: Integer range? |
Previous Message | Tom Lane | 2009-10-10 18:53:19 | Re: Building PG 8.4.1 with ossp-uuid on Centos 5.3 |