[Zope] Binary objects using psycopg postgresql adapter

Andreas Tille tillea@rki.de
Tue, 21 Jan 2003 21:25:39 +0100 (CET)


Hi,

I want to store binary objects (JPEG, PDF) into a PostgreSQL database.

I used to do this in plain Python via

    from psycopg import *

    ...
    binobj = Binary(file)
    query = "INSERT INTO Table (Id, binaryobject) VALUES (%d, %s)"
    curs.execute(query, (i, binobj))

If I want to do this in a python script I can not import psycopg
explicitely.  But if I use a Z Psycopg Database Connection 'ZPsyCon'
I can issue database queries using

    context.ZPsyCon.manage_test(query, REQUEST=None)

Is there any way to store binary objects via this method.

The only alternative I could see are External Methods.

Any hints how to do this right?

Kind regards

         Andreas.