Hi All,
Can anyone answer below question.
when to use use DBI; and when to use use DBD?
Thanks in advance
As and noted, DBI is the generic Perl database interface and DBD::* modules are the driver implementations for specific databases. In real code you normally put use DBI; at the top and call DBI->connect("DBI:driver:..."). DBI will load the appropriate DBD::... module at runtime if that driver is installed; you only explicitly use DBD::... when you need driver-specific constants or to force the module to preload.
Practical notes:
DBD::mysql) via CPAN or your package manager. Many DBDs require the database client development libraries present before installation (for example, install libmysqlclient-dev on Debian/Ubuntu before building DBD::mysql). perl -MDBD::mysql -e1 (exit 0 if found) or print the module version. For authoritative reference read the DBI and driver docs on CPAN: DBI documentation and DBD::mysql documentation. Best practice is to write driver-agnostic DBI code (use placeholders, RaiseError for simple error handling, and avoid embedding driver-specific SQL unless necessary).
Jump to Post— wickedxter 0DBD::mysql is a driver that allows you to work with a mysql server and DBI module depends on that driver module...
DBD::mysql is a driver that allows you to work with a mysql server and DBI module depends on that driver module...
DBI is database access library, DBDs are drivers used by DBI to access particular database.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.