On Wed, 4 Aug 2010 19:50:36 +0200, Jens Rehsack <rehs...@googlemail.com> wrote:
> 2010/8/4 H.Merijn Brand <h.m.br...@xs4all.nl>: > > http://www.xs4all.nl/~hmbrand/TD.tgz New version available as http://www.xs4all.nl/~hmbrand/Tie-DBD-0.01.tgz t/10_hash.t still has to be changed > > > > use DBI; > > use Tie::DBD; > > > > my $dbh = DBI->connect ("dbi:Pg:", ...); > > > > tie my %hash, "Tie::DBD", $dbh; > > tie my %hash, "Tie::DBD", $dbh, "foo"; > > > > $hash{key} = $value; # INSERT > > $hash{key} = 3; # UPDATE > > delete $hash{key}; # DELETE > > $value = $hash{key}; # SELECT > > > > Please edit t/10_hash.t to do what you need to do to connect to Postgres > > or Oracle. Support for MySQL, CSV, SQLite etc for later > > > > The reasoning behind this is that I have a small machine that connects > > to a database and does a lot of calculations. To `cache' calculated > > results, it uses a hash, which has outgrown the available memory space, > > so I tied that with "DB_File" to disk. The system however didn't give > > me enough space to store that, and the database server is huge and fast > > Hi Merijn, > > how does your module differ from Tie::DBI A lot, but I think my UI would fit in if I can convince Todd :) Tie::DBI maps to tables with fields tie %hash, "Tie::DBI", ...; $hash{$key_value}{field} = 1; Tie::DBD maps to a temp table with only a key and a value field tie %hash, "Tie::DBD", ...; $hash{$key_value} = 1; > (http://search.cpan.org/dist/Tie-DBI/)? > Or is it just a try to have a new start, because of the inactivity at > Tie::DBI? My intention was/is to have a DBI replacement for DB_File, so the *only* thing I have to change to use it is tie my %hash, "DB_File", "file.db", O_RDWR|O_CREAT, 0666; with tie my %hash, "Tie::DBD", $dbh; And the rest of my code will still work. With the current implementation of Tie::DBI I would have to rewrite everything. -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/