| From: | Greg Smith <gsmith(at)gregsmith(dot)com> |
|---|---|
| To: | Roger Mason <rmason(at)esd(dot)mun(dot)ca> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: wriring a file to a database |
| Date: | 2007-12-08 19:53:13 |
| Message-ID: | Pine.GSO.4.64.0712081442010.2045@westnet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Sat, 8 Dec 2007, Roger Mason wrote:
> I want to write a file into a database from python using psycopg.
You don't use lo_import directly for that. There is an example program
included with psycopg that shows the right syntax to insert a file. For
psycopg1, see bytea.py ; for psycopg2 look at binary.py
> curs.execute("INSERT INTO diamonds VALUES (%s,
> \lo_import(%s))",(iname, image))
> psycopg2.ProgrammingError: syntax error at or near "\" at character 50
Just so you know, the commands starting with \ like \lo_import are
specific to the psql client. None of those will work if you use another
tool to connect.
--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2007-12-09 00:09:33 | Re: How to EXPLAIN statements inside a trigger function? |
| Previous Message | Roger Mason | 2007-12-08 19:02:55 | wriring a file to a database |