Re: [SQLObject] Binary support for Postgres using psycopg2's Binary type
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ma...> - 2005-01-12 12:38:49
|
Oops, third followup to myself... On Wed, Jan 12, 2005 at 03:03:52PM +0300, Oleg Broytmann wrote: > On Wed, Jan 12, 2005 at 02:40:59PM +0300, Oleg Broytmann wrote: > > registerConverter(type(psycopg.Binary(None)), > > TypeError: argument 1 must be str, not None > > I replaced None with an empty string '' - and it works! The test > passed. psycopg 1.1.13 on Postgres 7.2. If nobody objects I'd like to > commit the patch. Or may be anyone would like to extend it for MySQL and/or SQLite? For MySQL there, probably, whould be a parameter 'size' or 'maxsize' to distinguish between TINYLBLOB, BLOB, MEDIUMBLOB and LONGBLOB. Something like this: class SOBLOBCol(SOStringCol): def _mysqlType(self): length = self.length varchar = self.varchar if length >= 2**24: return varchar and "LONGTEXT" or "LONGBLOB" if length >= 2**16: return varchar and "MEDIUMTEXT" or "MEDIUMBLOB" if length >= 2**8: return varchar and "TEXT" or "BLOB" return varchar and "TINYTEXT" or "TINYBLOB" Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |