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")
[('(1,"The rain in Spain falls mainly in the plains.")',),
('(2,"Twenty dwarves did handstands on the carpet.")',),
Automatic Pickle Serialization and Deserialization with PostgreSQL
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.
A Tale of PostgreSQL Types and Python
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: