Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > is there a module to work with pickled objects storage in database?

Reply
Thread Tools

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

 
 
krishnakant Mane
Guest
Posts: n/a
 
      05-04-2007
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.
 
Reply With Quote
 
 
 
 
Paul Boddie
Guest
Posts: n/a
 
      05-04-2007
On 4 Mai, 12:18, "krishnakant Mane" <(E-Mail Removed)> wrote:
>
> 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

 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      05-04-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does pickled objects work fine between different OS? Oltmans Python 3 05-26-2010 04:23 PM
Re: Pickled objects over the network Jean-Paul Calderone Python 3 07-19-2007 09:25 PM
Latest errors on pickled objects and blob datatypes in mysql krishnakant Mane Python 2 05-07-2007 05:57 PM
how fast can you pingpong pickled objects? Bram Stolk Python 0 12-12-2005 04:22 PM
how do I read a series of pickled objects from a socket? Ryan Grow Python 1 11-16-2004 09:17 PM



Advertisments