Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Class::DBI::Loader and Postgres schemas

by srdst13 (Pilgrim)
on Oct 05, 2005 at 14:49 UTC ( #497618=perlquestion: print w/replies, xml ) Need Help??
srdst13 has asked for the wisdom of the Perl Monks concerning the following question:

I have a rather large postgres database with multiple schemas in it. I would like to use Class::DBI::Loader to autogenerate the Class::DBI classes, but only for a single schema. Under DBI, I would typically do something like:
$dbh->do("set search_path to $SCHEMA")
to limit access to a given schema. Is there a way to do this with Class::DBI::Loader?

Thanks,
Sean

Replies are listed 'Best First'.
Re: Class::DBI::Loader and Postgres schemas
by ides (Deacon) on Oct 05, 2005 at 15:39 UTC
    Not currently, but it appears you can hack it to work. In Class::DBI::Loader::Pg.pm there is a line:
    return $dbh->tables( undef, "public", "", "table", { noprefix => 1, pg_noprefix => 1 } );
    Replace the "public" with the name of your schema and it should work as you want.

    UPDATE: I've sent a patch off to the maintainer for this so hopefully it will be in the next release for you.

    Frank Wiles <frank@wiles.org>
    http://www.wiles.org

      Always good to hack. Thanks for sending off the patch. I guess it should also be possible to override db_main using another base class (?), but I haven't tried that yet.

      Sean

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://497618]
Approved by Corion
help
Chatterbox?
[msh210]: perl -e'warn "test$/", "" '
[msh210]: doesn't append anything.
[msh210]: It should say "If the last nonempty element of LIST" or "If the string thus to be printed does not end in a newline""
[msh210]: Am I wrong?
[shmem]: no. You're right.
[msh210]: About time... last time I was right was... I don't even remember when.
[shmem]: perl -e 'warn "test$/", ^@^ '
[Eily]: well, at least it's right about warn doing the same thing as die :)
[shmem]: same with undef as last element
[msh210]: oh, good point. It's the best kind of correct

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (19)
As of 2017-04-24 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.