Yeah, psycopg needs a hint that it's binary. Wish the damn thing were documented better.
Something like this with a cursor object:
cursor.execute('insert into foo (blob) values (%s)', [psycopg.Binary(data)])
On 12/31/05, Michael Bayer <[EMAIL PROTECTED]> wrote:
well I havent worked with blob types on postgres as of yet. does it need to use the DBAPI "Binary" contstructor ? right now the blob value is just bound to a bind parameter like any other value and sent into cursor.execute() with no processing. If you can show me (or I will figure out) what the proper methodlogy is, it just gets built onto the PGBinary type within the convert_bind_param and convert_result_value methods as appropriate (or perhaps onto the base Binary type).
On Dec 31, 2005, at 7:03 PM, Jonathan Ellis wrote:
from sqlalchemy import *
import urllib# CREATE TABLE foo (
# id serial PRIMARY KEY,
# blob bytea
# ) WITH OIDS;engine = create_engine('postgres', ...)
foo = Table('foo', engine, autoload = True)
class Foo(object): pass
assign_mapper(Foo, foo)f = Foo()
f.blob = urllib.urlopen('http://schlockmercenary.com/comics/schlock20051231.png').read()
print len(f.blob) # 38201
objectstore.commit ()# select octet_length(blob) from foo;
# octet_length
# -------------
# 8
--
Jonathan Ellis
http://spyced.blogspot.com
--
Jonathan Ellis
http://spyced.blogspot.com

