Alex Rivera | Logout

PostgreSQL export large object to client

Asked 2012-01-09T10:36:00.793
10

I have a PostgreSQL 9.1 database in which pictures are stored as large objects. Is there a way to export the files to the clients filesystem through an SQL query?

select lo_export(data,'c:\img\test.jpg') from images where id=0;

I am looking for a way similar to the line above, but with the client as target. Thanks in advance!

Edit
Report

1 Answer

14

this answer is very late but will be helpful so some one i am sure

To get the images from the server to the client system you can use this

"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.101 -p 5432 -d mDB -U mYadmin -c  "\lo_export 19135 'C://leeImage.jpeg' ";

Where

  1. h 192.168.1.101 : is the server system IP
  2. -d mDB : the database name
  3. -U mYadmin : user name
  4. \lo_export : the export function that will create the image at the client system location
  5. C://leeImage.jpeg : The location and the name of the target image from the OID of the image
  6. 19135 : this is the OID of the image in you table.

the documentation is here commandprompt.com

answered 2012-02-17T06:18:18.043

Your Answer