Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

ODBC vs DBI

by SageMusings (Beadle)
on May 02, 2001 at 23:25 UTC ( #77471=perlquestion: print w/replies, xml ) Need Help??

SageMusings has asked for the wisdom of the Perl Monks concerning the following question:

Enlightened bodhisatvas,
I beg to interrupt your meditations with my unworthy question. I have gathered from conversations I have read on this site and others that ODBC is deprecated in favor of DBI. Is this true? If so, why? I have written many scripts using the ODBC interface on NT machines with great success. As I have no knowledge of DBI yet, I thought I could find out if it was worthwhile for me to learn. Can DBI interface to an Access DB on an NT mcahine? Should I retrofit my programs?
Many thanks, O' clear thinkers....

Replies are listed 'Best First'.
Re: ODBC vs DBI
by merlyn (Sage) on May 02, 2001 at 23:30 UTC
    I think you're mixing up layers.

    DBI is the interface your Perl program uses to the high-level database routines. Those routines in turn call the low-level backend routines that are database specific.

    One of these backend routines is ODBC, which itself is an indirection layer to let many databases have a similar API.

    So it'd go yourcode -to- DBI -to- DBD::ODBC -to- random back end

    Sure, you can certainly talk directly to ODBC, but then you'd lose the option to go with a non-ODBC backend by changing just a few lines of code, such as mysql via: yourcode -to- DBI -to- DBD::mysql -to- mysql API.

    So, ODBC doesn't replace DBI. DBI doesn't replace ODBC. They're indirections at different levels.

    -- Randal L. Schwartz, Perl hacker

Re: ODBC vs DBI
by thabenksta (Pilgrim) on May 03, 2001 at 00:06 UTC

    I had used Win32::ODBC; on NT machines for a while. It always worked fine for me. Then I had to start using DBI, cause of a new job. While I think Win32::ODBC was easier to learn, once I learned DBI, it made it easier to deal with more complicated tasks. Plus if you ever have to move the application to a *nix machine you wont have to re-code your database programs.

    Another benifit of DBI is that it is much more widely supported, which means more people will be able to help you out of a jam.

    So if you feel more comfortable with ODBC, then stick with it, but I, and prolly most eveyone here would recomend learn DBI.

    To answer you question more directly, Yes, you can make DBI use the ODBC(seperate from Win32::ODBC) interface to get to an Access DB on NT.

    -thabenksta
    my $name = 'Ben Kittrell'; $name=~s/^(.+)\s(.).+$/\L$1$2/g; my $nick = 'tha' . $name . 'sta';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://77471]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2022-08-16 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?