Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: store/retrieve data structure in MySQL

by rnahi (Curate)
on Jul 31, 2005 at 21:33 UTC ( [id://479744]=note: print w/replies, xml ) Need Help??


in reply to store/retrieve data structure in MySQL

You may use Apache::Session::MySQL.

Despite the name, and despite being designed for using with mod_perl, you can use it even in a non-web application. Or, as the docs say

it can also be used for any situation where data persistence is desirable.

It's a ready to use framework. Look at the docs. It's quite easy to store a data structure into a database table, and even to use it with a tied hash.

Replies are listed 'Best First'.
Re^2: store/retrieve data structure in MySQL
by hakkr (Chaplain) on Aug 01, 2005 at 15:37 UTC
    Note, it can be a bad idea to do this, instead of having a proper db design.

    I have seen a coworker just use Data::Dumper to store text repsentations of objects. He then ends up using Regexp queries to search within db fields for object attributes. So he is storing more information than required and losing many rdbms features.

    Tying your data to your dev language is obviously not a great idea for portability either. Anyway you dump it ,then you eval it as pseudo below. You will probably have to use a string rather than binary representation if you wish to search the data easily. As you are using a blob field you will have to use storable instead.

    #get string representation for insert into db my $data={}; use Data::Dumper; my $serial=Dumper($data); #get object back from string my $obj=eval $serial;
      I store all the properties of the object within the database in a nice normalized structure....this was only needed for use within a summary table for optimization reasons. I build the objects rarely so why not cache them? :-)

      Thanks everyone for the help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://479744]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found