DBI - Database independent interface for Perl | Search for a title, author or keyword | ||||||||
DBI - Database independent interface for Perl The DBI is the standard database interface module for Perl. It defines a set of methods, variables and conventions that provide a consistent database interface independent of the actual database being used. The DBI module enables your Perl applications to access multiple database types transparently. You can connect to MySQL, MSSQL, Oracle, Informix, Sybase, ODBC etc. without having to know the different underlying interfaces of each. The API defined by DBI will work on all these database types and many more. DBI ( DataBase Indipendent ) doesn't know how to talk to any particular database, but it does know how to locate and load in DBD ( `Database Driver', DataBase Dipendent ) modules. The DBD modules have the vendor libraries in them and know how to talk to the real databases; there is one DBD module for every different database. When you ask DBI to make a query for you, it sends the query to the appropriate DBD module ( let's say it's DBD::Oracle ), which spins around three times or drinks out of its sneaker or whatever is necessary to communicate with the real database. When it gets the results back, it passes them to DBI. Then DBI gives you the results. DBD::Oracle, in our example, knows how to translate what it gets from DBI into the format demanded by the Oracle library, which is built into it. There are two big wins that result from this organization. First, you don't have to worry about the details of talking on the network to the Oracle server or dealing with Oracle's library. You just have to know how to talk to DBI. Second, if you build your program to use Oracle, and then the following week upper management signs a new Strategic Partnership with Sybase, it's easy to convert your code to use Sybase instead of Oracle. You change exactly one line in your program, the line that tells DBI to talk to DBD::Oracle, and have it use DBD::Sybase instead. There are DBD modules for talking to every important kind of SQL database. DBD::Oracle will talk to Oracle, and DBD::Sybase will talk to Sybase. DBD::ODBC will talk to any ODBC database including Microsoft Acesss ( ODBC is a Microsoft invention that is analogous to DBI itself. There is no DBD module for talking to Access directly ). DBD::CSV allows SQL queries on plain text files. DBD::mysql talks to the excellent MySQL database. It is important to remember that the DBI is just an interface. The DBI is a layer of "glue" between an application and one or more database driver modules. It is the driver modules which do most of the real work. This is the DBI specification that corresponds to the DBI version 1.613. The DBI is evolving at a steady pace, so it's good to check that you have the latest copy.
|
|||||||||
DBI - Database independent interface for Perl | Disclaimer: this link points to content provided by other sites. |