Storing objects in relational database
bruno.desthuilliers at gmail.com
bruno.desthuilliers at gmail.com
Fri May 23 17:36:37 EDT 2008
On 23 mai, 23:14, nayden <nay... at gmail.com> wrote:
> and then I try to restore the object with the following code
>
> def success(rv):
> print "success"
> str = cStringIO.StringIO(libpq.PgUnQuoteBytea(rv[0][0]))
> i = cPickle.load(str)
> i.toString()
>
> the execution fails just after the print statement, and I am not quite
> sure why is that.
Please reread the doc for pickle.dump, pickle.dumps, pickle.load and
pickle.loads. You just don't need StringIO here, just use the 's
versions of the functions.
> I would love to find out what people are using when they need to do
> something similar
> perhaps I am trying to do it the perl way, while there is an elegant
> python solution.
I don't know if you'd label it 'elegant', but as far as I'm concerned,
storing serialized objects as blobs in a relational database is mostly
non-sense. If I use a relational database, it's because it is a
*relational* database. If you want an OODB, then we have the ZODB,
Durus and a couple others.
More information about the Python-list
mailing list