Automatic Pickle Serialization and Deserialization with PostgreSQL

Posted by: troy Tue, 13 Jun 2006 04:00:00 GMT

Building on the earlier success of creating a pickle data type in PostgreSQL, I've come up with this small and comfortable way of automatically serializing and de-serializing python pickles with PostgreSQL and psycopg2.

Read more...

Posted in ,  | no trackbacks

SELECT Surprise

Posted by: troy Tue, 13 Jun 2006 04:00:00 GMT

While experimenting with unicode values in Python, PostgreSQL and pyscopg2, I ran a little query like this:

>>> cur.execute("SELECT (note_id, body) FROM troy.morenotes")
>>> cur.fetchall()
[('(1,"The rain in Spain falls mainly in the plains.")',),
 ('(2,"Twenty dwarves did handstands on the carpet.")',),
 ('(5,I\xc3\xb1t\xc3\xabrn\xc3\xa2ti\xc3\xb4n\xc3\xa0liz\xc3\xa6ti\xc3\xb8n)',)]
Read more...

Posted in ,  | no comments | no trackbacks

A Tale of PostgreSQL Types and Python

Posted by: troy Tue, 06 Jun 2006 04:00:00 GMT

Thinking of integrating user-defined types in PostgreSQL and psycopg2? Here's the path I walked, hopefully you can avoid the same pitfalls.

I was after a PostgreSQL data type for storing Python pickles. This seemed simple enough because the database facility for aliasing a type already exists. So the first thing I tried was a CREATE DOMAIN statement in PG, like so:

Read more...

Posted in ,  | no trackbacks