Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: store/retrieve data structure in MySQL

by rnahi (Curate)
on Jul 31, 2005 at 21:33 UTC ( #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.

  • Comment on Re: store/retrieve data structure in MySQL

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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2020-05-25 09:08 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (144 votes). Check out past polls.