473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.
May 4 '07 #1
2 1181
On 4 Mai, 12:18, "krishnakan t Mane" <researchb...@g mail.comwrote:
>
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

May 4 '07 #2
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.

May 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1905
by: aum | last post by:
Hi, I'm looking for an object-relational layer, which can wrap a MySQL database into highly pythonic objects. There seem to be dozens of packages which provide some of this functionality, but all the ones I've looked at so far have major drawbacks. What I'm looking for in an object-relational wrapper layer is:
2
2140
by: sh | last post by:
Hi guys, Well, I have a (maybe dumb) question. I want to write my own little blog using Python (as a fairly small but doable project for myself to learn more deaply Python in a web context). I don't want so far to use a database as a backend, I'd prefer use XML which is enough for a small amount of data the blog would have to deal with.
18
3051
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases...
1
4238
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
9
2548
by: Joseph Wakeling | last post by:
Hello all, I sometimes make use of global variables within modules, which I denote with "static" so that they will not be seen outside the module, and will preserve values between module calls. Recently I was looking back at a rather important function and found I'd forgotten to put the static declaration in place. I'm not worried about any interference with outside---the variable names are unlikely to be reproduced elsewhere---but I...
4
3744
by: David Hirschfield | last post by:
I have a pair of programs which trade python data back and forth by pickling up lists of objects on one side (using pickle.HIGHEST_PROTOCOL), and sending that data over a TCP socket connection to the receiver, who unpickles the data and uses it. So far this has been working fine, but I now need a way of separating multiple chunks of pickled binary data in the stream being sent back and forth. Questions:
9
1410
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little with threads and am looking for some pointers on how to implement, and if the lower level modules/objects need to be rewritten to use threading.local for all local variables. I have a module that communicates with a hardware device, which reads...
5
7656
by: mrbog | last post by:
My server was working fine (no one else changes it but me, it's a local server on my lan), and all of a sudden I get: Fatal error: session_start(): Failed to initialize storage module: user... It didn't even happen after like a reboot or something, it just happened one morning. I fixed it by changing:
4
7564
by: Daniel | last post by:
Hello, I'm trying to build a very simple IPC system. What I have done is create Data Transfer Objects (DTO) for each item I'd like to send across the wire. I am serializing these using cPickle. I've also tried using pickle (instead of cPickle), but I get the same response. Below is the code. I'll put the rest of my comments after the code
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.