Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a friendly module that allows querying a MySQL database from Perl?

Tags:

sql

mysql

perl

Searching CPAN yielded so many results I don't know where to start. I need a simple and friendly module for some basic querying.

like image 813
David B Avatar asked Nov 07 '10 11:11

David B


People also ask

What is DBI module in Perl used for?

For connecting to and querying a database, Perl provides a module called DBI. DBI is a database interface for communicating with database servers that use Structured Query Language (SQL) to get data. Accessing a Database in Perl generally takes two steps. The DBI module provides an API for database access.


2 Answers

For raw SQL queries, you'll need DBI and DBD::mysql. But I highly recommend that you also install and use DBIx::Class - it'll make your life far easier.

like image 171
Dave Cross Avatar answered Oct 07 '22 19:10

Dave Cross


Main database module at CPAN is DBI. All other modules (except very little group) use DBI. DBI has drivers for databases. For MySQL it is called DBD::mysql. With DBI you can write crossdatabase Perl code. Of course you will need to alter SQL code in case you are using DBMS-specific features.

P.S. And look at placeholders.

like image 38
Alexandr Ciornii Avatar answered Oct 07 '22 18:10

Alexandr Ciornii