On Friday 30 October 2009 09:42:15 am Jacek Kałucki wrote:
> Użytkownik John napisał:
> > Paul, Larry was able to get Dabo to accept the binary data. However, we
> > followed the idea that each DB adapter had a "fixBinaryData()" method
> > that made the correct conversion to allow Dabo to save/update/insert.
> > Other code changes were done too. But my point is I still think in the
> > end having a backend method is going to be a requirment.
> >
> > For example in the case of Postgres
> >
> > def fixBinaryData(self, val):
> > return psycopg2.Binary(val)
>
> Hi,
>
> I tried to solve problem my own way.
> I tried to encapsulate binary data in dNoEscQuoteStr object, although
> noticed two problems:
> - first, we need to modify dNoEscQuoteStr class to accept buffer type
> object, e.g.:
> def __str__(self):
> if not isinstance(self._value, str):
> ret = array.array("c", self._value).tostring()
> else:
> ret = self._value
> return ret
> - second, we need to correct sql expression formatting in
> dCursorMixin.__saverow() method
> to avoid UnicodeDecodeError exception.
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.
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]