On Fri, May 21, 2010 at 6:47 PM, Yang Zhang <yanghates...@gmail.com> wrote: > I'm trying to run the following: > > session.query(Activity).filter(Activity.blob == blob).one() > > where Activity.blob is a BLOB and blob is a Python bytes object > (equiv. to str in Python 2.x). But although I can insert Activity(blob > = blob) objects fine, the above query fails with: > > ProgrammingError: (ProgrammingError) You must not use 8-bit > bytestrings unless you use a text_factory that can interpret 8-bit > bytestrings (like text_factory = str). > > This is because blob has to be wrapped with sqlite3.Binary(blob). Why > doesn't sqlalchemy automatically do this casting, given that it has > schema awareness? Is there any way to avoid having to do this for > every such query? > > Thanks in advance. > -- > Yang Zhang > http://yz.mit.edu/ >
Also, how do I do the wrapping portably? For sqlite3 I have to wrap with sqlite3.Binary, for postgresql I have to wrap with psycopg2.Binary, etc. -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.