Class::DBI::Loader 0.10 (with automatic relationships!)

[prev] [thread] [next] [Date index for 2004/12/15]

From: Sebastian Riedel
Subject: Class::DBI::Loader 0.10 (with automatic relationships!)
Date: 03:40 on 15 Dec 2004
--=-H6lqwJjwT383YiC0EXvi
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I really liked Randal's article "Creating Class::DBI relationships
automatically" and thanks to some other people bugging me with patches
for Class::DBI::Loader i spent some time to refactor it a bit today.

Attached is a first try which works well with PostgreSQL.
SQLite seems not to support foreign keys and MySQL may work but i don't
use it...so reports welcome...

It's quite easy to use.


  CREATE TABLE foo (
      id SERIAL NOT NULL PRIMARY KEY ,
      yada TEXT
  );

  CREATE TABLE bar (
      id SERIAL NOT NULL PRIMARY KEY,
      foo INT REFEENCES foo (yada)
  );


  use Class::DBI::Loader;
  my $loader = Class::DBI::Loader->new(
    dsn           => "dbi:Pg:dbname=foobar",
    user          => "postgres",
    password      => "",
    namespace     => "Data",
    relationships => 1,
    debug         => 1
  );


I'll upload 0.10 to CPAN if there are no complaints...

Eat my shorts Java! =)

        -- 
        sebastian

--=-H6lqwJjwT383YiC0EXvi
Content-Disposition: attachment; filename=Class-DBI-Loader-0.10.tar.gz
Content-Type: application/x-compressed-tar; name=Class-DBI-Loader-0.10.tar.gz
Content-Transfer-Encoding: base64

H4sICF+sv0ECA0NsYXNzLURCSS1Mb2FkZXItMC4xMC50YXIA7V17e9rG0vff+hRT6nOAFAPieoob
N8QmrU98oYDbk6cXHgELqBESlkQc13E/+zt7kbQCCWzsOElf7dPUoJ29zc7u/HZmtBwamuPsHb08
3juxtBGx94p5tVjYedRUxFSvVulftV4tyn+9tKMW1Wq9Xqqp5fpOEf9XquxAdecJ0sJxNRtgx7H1
tXSb8r2BeH+/kHQYOf9u4dPOf0Wt1ZP5/5TzX1T7s2vn0si7jzP/tUolbv7LdbXG579WqdYqdP5r
xXJtB4rJ/D/B8Ak4rq0P3X2Ffu4Rx200Ti2bgIsfHXh+ALV9heUxWWk0UFg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T0Aol8+0SJ
g1kb3hJX4qMIlfUXzChr4w+U8O2UivxjlYp/c70S+g0jxTvRwIZ0ytAWzIir7VF/HmRwW+P2JR9p
Zf9BPqvo9c+l4bHa2OT/UYPzX6lapuu/Uq0n8Z9PkpiXZulItLWjxvfQ+NdfxjlpHnSN912dNfdw
2NzRaXMPx80jOG/u78C5lxPnDo4c6Yryx3DoyBeFxzl1PMFZcuywOMlI5w5NUQ6edRL4MAG8s8it
FbJYsVoRJI8t6xxA3mglJxBnzGZHkMeKOziDZCdQzKaxhR+IXa67hS+ISfvD/EE03dGLw10xd/IL
bVHrHfxDEukmH9HdOxA3jXfzFdHC1F+0xgCPVMJvwomXXScpyXOS8mgDlwkttOw1SS07TbBc4C3h
v13yMIeJ5ylhdrvHcZaIX7KivN3kMPE9JeG5ya0GSeaWXp3IRVyjl4uZYn+GcvHxifFll9tautIu
ier6sv0/wenvKc7/kv23VKe//1qt1RP7787TDJ9EORNQ1/9i40L2BIHDoDQ9LaRDiDLiNwD4ppEW
kWF9erlhmtHG2BG8Au1Oq9P6qd8+TXtXy/jgSPpVArl16jORbqcJ4EWY6D/fBkShXAns5svFgCjC
n8NqEhfdKNkkajVJSUpSkpKUpCQlKUlJSlKSkpSkJCUpSUlKUpKSlKQkfb7p/wCgwJMhAKAAAA==


--=-H6lqwJjwT383YiC0EXvi--

Class::DBI::Loader 0.10 (with automatic relationships!)
Sebastian Riedel 03:40 on 15 Dec 2004

Generated at 09:04 on 20 Dec 2004 by mariachi v0.52