On Friday 30 October 2009 11:34:24 am Jacek Kałucki wrote:
> Użytkownik John napisał:
> > Larry can best respond but I think what you did is similar to his
> > thinking. He just hard coded the changes required.  However, even after
> > making his code changes in the Framework.  It turned out the data was not
> > in the correct format for DB.  IOW's the backend complained about the
> > data.
> >
> > That's when I added the method in the db adapter.  It could be my lack
> > experience with binary data but I could not get
> > img = buffer(open('whereareyou.jpg').read()) and several other ways
> > to work.  However, I was able to get it to work using the
> > psycopg2.Binary() function.
> >
> > I think this maybe a problem with other DB's too - else why do they
> > provide the functions to deal with binary data.
>
> Among psycopg2 examples, there is one using both "buffer" and "Binary"
> function.
> In pure python, both works for me fine.
> The reason is, because before string is written into PostgreSQL, it is
> parsed (even twice)
> by server engine (read pgSQL 8.3 documentation chaper no. 8.4).
> They do provide such functions to simplify life :)
> But there are solutions that works with all databases universally, like
> this:
>      INSERT INTO btable (bvalue) values(decode(‘%s’,'base64′));
>      SELECT encode(bvalue,’base64′) FROM btable;

Yea that's similar to the code I was attempting to get to work.  I'm not the 
most talented python coder nor the best SQL coder.  So I could have missed 
something.  I'm all in favor of getting a universal way to getting it done.

Johnf


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to