Perls Before Swine: SQL database

  1. Creating files
  2. Perls Before Swine
  3. Web CGIs

One of the most common things Perl is used for when it comes to raw data files is importing them into databases. To import into databases in Perl, you need a special module. This is normally the DBI module, and you’ll access it by putting a “use” line at the top of your script. This tells Perl that you want to access an external module for more functionality.

use DBI;

$dbh = DBI->connect("dbi:SQLite:dbname=TESTDB");

Put this just below your first set of comments, and then run

./show

If it shows you your help as normal, then you have both DBI and SQLite installed on your system.

If it gives you the error “Can’t locate DBI.pm in …”, you’ll need to install DBI and SQLite.

If it gives you the error “install_driver(SQLite) failed: Can't locate DBD/SQLite.pm in @INC…”, this means that you have DBI but you’ll need to install SQLite.

  1. Creating files
  2. Perls Before Swine
  3. Web CGIs