On Thu, Jul 23, 2009 at 04:54:11PM +1200, Aaron Robinson wrote:
> I'm wanting to write some binary data to the database - specifically the
> data is produced by something like:
>     array.array('H',[1,2,3]).tostring()
> and the database is Postgres 8.3 with a sqlobject.BLOBCol(default=None)
> column.
> 
> Currently when I try this I receive this error:
>     DataError: invalid byte sequence for encoding "UTF8": 0x83
>     HINT:  This error can also happen if the byte sequence does not match
> the encoding expected by the server, which is controlled by
> "client_encoding".

   Ouch. Can you write a short test program that demonstrates the problem?
What version of SQLObject do you use? what are the encodings of client and
server?

> I ran into a vaguely similar post, and the suggestion was to
> useUnicodeCol(), which I have tried and received the same result.

   UnicodeCol is for text, not binary data.

> Basically the main focus here is on keeping the storage size in the DB as
> low as possible, as we want to store many groups of numbers (all below
> 65536), and there is no need (or desire) to store them in individual
> columns.

   There is also PickleCol - a subtype of BLOBCol that can store any
pickleable data - the column (un)pickles data as necessary.
   A problem with the column (and your approach with array.tostring) is
that you cannot search or sort results by values in these columns.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to