Reading BLOB

Peter Hansen peter at engcorp.com
Wed Jan 21 14:30:30 EST 2004


Johan.Vervoort at utimaco.be wrote:
> 
> This is the sample code: It should dump all the certificates to the
> certs directory...
> What I suspect is that python thinks that the certif field is a STRING
> and it's truncated when the first '\0' occurs...
> (The data is stored completely in the database as an equivalent
> C-program works fine...)

Python itself does not care about '\0' in a string, and will happily
handle strings with any kind of binary data.

At the least, then you need to look lower, perhaps at the ODBC wrapper
code itself, perhaps at the database schema or something.  Are there
multiple types of string that can be stored in the database, and you've
picked one that is effectively null-terminated?  Or, wait a minute, your
subject line is "reading BLOB", yet you are dealing with strings in
some way, given this:

>>> reload (Test)
[('csernum', 'STRING', 80, 80, 0, 0, 0), ('certif', 'STRING', 0,
2147483647, 0, 0, 0)]

Surely that is the cause of the problem, at least indirectly?  Isn't
there some kind of BLOB data type instead?

-Peter



More information about the Python-list mailing list