1

Python 2.7
psycopg2

When I run:
cur.execute("SELECT lo_export(123456, '/tmp/test.jpg')")

Produces error - need to be superuser to do this.

This makes sense as it is running a server side lo_export and the permissions are not set to superuser for the user I want to run the request.

I want to run a client side lo_export as if I was running psql.

Can I do this within an open psycopg2 connection?

1

OK simple solution. Use:

conn = psycopg2.connect("db=dbname etc etc")  
lo = conn.lobject(12345)  
lo.export('/tmp/test.jpg')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.