is there a module to work with pickled objects storage in database?

  • Thread starter krishnakant Mane
  • Start date
K

krishnakant Mane

hello all,
I am trying a very complex kind of a task in a project.
I have a knowledge management system where I need to store a lot of
objects (pickled). I have to store mostly lists and dictionaries into
a rdbms.
mostly I will be using mysql. I want to know if there is any module
that can help me store a pickled object inside a blob field instead of
a file. I know that pickle.dump() can store an object into a file but
I can't find a way to transfer pickled objects into a database.
I so far tried to read a dumpped file for pickled object and directly
right the contents of the file to the blob field in my database.
but that does not seam to give the right result.
I first dump the object into the file through pickle.dump and then
open the file in read mode.
then I read the contents of the file and then store what ever comes
out into the blob field.
I know this is not right and there should be ways of storing a pickled
object other than file.
Please guide me on this issue.
regards.
Krishnakant.
 
P

Paul Boddie

I first dump the object into the file through pickle.dump and then
open the file in read mode.
then I read the contents of the file and then store what ever comes
out into the blob field.
I know this is not right and there should be ways of storing a pickled
object other than file.

Try pickle.dumps to produce a string containing the pickled object.
Obviously, you then need to supply the string to the database using
the normal DB-API mechanisms. That said, although I haven't done much
work with BLOBs in the DB-API, it would surprise me if it were not
possible with some database modules to pass a file-like object as a
parameter to the cursor's execute method, although I don't recall
there being any classes whose objects act like files and produce
pickled objects on demand.

Paul
 
B

Bruno Desthuilliers

krishnakant Mane a écrit :
hello all,
I am trying a very complex kind of a task in a project.
I have a knowledge management system where I need to store a lot of
objects (pickled). I have to store mostly lists and dictionaries into
a rdbms.

Which totally defeats the purpose of a rdbms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top