CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
DBI Compatability

 



Dubbs1231
newbie

Mar 13, 2001, 6:06 PM

Post #1 of 7 (1236 views)
DBI Compatability Can't Post

What databases is the DBI module compatable with? I'm writing a CGI script and i'm using DBI. I have mysql on my server, but i was wondering what other databases DBI is compatable with.

Thanks for your help!

God Bless

Erich Musick



Jasmine
Administrator / Moderator

Mar 13, 2001, 8:23 PM

Post #2 of 7 (1233 views)
Re: DBI Compatability [In reply to] Can't Post

DBI can be used as the bridge to many different database types (with more being added frequently).

As long as you, don't use any database specific statements, the program should be portable just by using a different DBD (database driver).

A list of DBD modules is at cpan



Dubbs1231
newbie

Mar 14, 2001, 8:07 AM

Post #3 of 7 (1224 views)
Re: DBI Compatability [In reply to] Can't Post

Thanks for your help!

One other question - is there a way I can find out what commands are database independent? Like i said, I'm writing this with MySQL and am using the mysql documentation for reference. is there a better site to use for reference that is database independent?

Thanks for your help!

Erich Musick



Jasmine
Administrator / Moderator

Mar 14, 2001, 10:37 AM

Post #4 of 7 (1222 views)
Re: DBI Compatability [In reply to] Can't Post

I'm not aware of a database independent reference, but Programming the Perl DBI (Alligator Descartes & Tim Bunce) is an excellent book if you're interested in DBI programming.



Dubbs1231
newbie

Mar 16, 2001, 6:53 PM

Post #5 of 7 (1209 views)
Re: DBI Compatability [In reply to] Can't Post

is there a way to automatically determine which DBD module to use?

when i connect, i use:
my $dbh = DBI->connect("DBI:mysql:database=$CONF{'database'};host=localhost", "$CONF{'username'}", "$CONF{'password'}") or &error("<I>Couldn't connect to database:</I> " . DBI->errstr);

if i were using oracle, it would look like
my $dbh = DBI->connect("DBI:oracle:database=$CONF{'database'};host=localhost", "$CONF{'username'}", "$CONF{'password'}") or &error("<I>Couldn't connect to database:</I> " . DBI->errstr);

what do i do to get it to automatically determine the part i put in bold?



Jasmine
Administrator / Moderator

Mar 17, 2001, 1:49 AM

Post #6 of 7 (1205 views)
Re: DBI Compatability [In reply to] Can't Post

It's probably not the best way to do it, but you can use dbi to grab the list of available drivers then "pick one".


Code
use DBI; 

my @drivers = DBI->available_drivers();

@drivers will contain a list of drivers that are installed on the server. Note that it doesn't check to see if the drivers are installed properly -- just that they're installed.



Dubbs1231
newbie

Mar 17, 2001, 8:36 AM

Post #7 of 7 (1199 views)
Re: DBI Compatability [In reply to] Can't Post

Thanks! That helps a lot! :)

God Bless,

Erich Musick


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives