getting serialized data into and out of a database

Michael Pelz Sherman mpelzsherman at yahoo.com
Tue Oct 30 09:25:32 EDT 2007


THANK YOU! I needed to use tostring() in this case but the key was realizing what kind of data I was dealing with.

Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote: En Mon, 29 Oct 2007 19:07:18 -0300, Michael Pelz Sherman  
 escribió:

> I'm having a devil of a time getting serialized data into and out of a  
> database (MySQL in this case) using python and MySQLdb.
>
> I have some C code that has its own serialization/deserialization  
> functions, which we've wrapped using SWIG.
>
> I am able to save the serialized C structs to disk but when I try to  
> write the exact same data to MySQL and pull it back out, I'm getting  
> some strange results. The data comes back looking like this:
>
> array('c', '\x01r\x01\x00\x...)
>
> Is this a python buffer, or what? How can I access the data in there?  
> I've tried using [1] but that doesn't seem to work.

It's an array of characters 
You can write it to disk again using its tofile() method

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071030/82ec3214/attachment.html>


More information about the Python-list mailing list