Re: [SQLObject] SQLite fails for binaries
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Javier R. <jav...@Ho...> - 2003-09-07 23:54:02
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joshua Rothenberg wrote: > > Well having made that change and tested various things extensively I still have absolutely no clue what's going on, but now when I try to read the img data it tells me "Error: Incorrect padding"... It looks like, among other things, \n's are being turned into \\n's and not being converted back properly (this is from using short strings instead of full images; everything just seems to get garbled with big images).. And it still works properly under PostgreSQL. I have no idea if the problem is with my code, SQLObject's SQLite interface, PySQLite, or SQLite. Although since it *does* work in other database systems its probably one of the latter three. Hasn't anyone had this problem before? > > Joshua Rothenberg Joshua, I had the same problem some time ago. Make your getter function use unQuote. def _get_stuff(self): def unQuote(val): # This list is from SQLObject/Converters.py. sqlStringReplace = [ ('\\', '\\\\'), ('\'', '\\\''), ('\000', '\\0'), ('\b', '\\b'), ('\n', '\\n'), ('\r', '\\r'), ('\t', '\\t') ] for final, original in sqlStringReplace: val = val.replace(original, final) return val # Using pickle instead of base64. # I don't think it makes a difference. from cPickle import loads return loads(unQuote(self._SO_get_valor())) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE/W8Vj8XQC840MeeoRAtP2AJ0QTtkjvr6m6+RWFaaaFKjRVg5XtQCeJvjx EfLO6arjeiADPPnDdxBzvIk= =DPch -----END PGP SIGNATURE----- |