Skip to content
yuki-kimoto edited this page Sep 7, 2012 · 2 revisions

Connect to SQLite

DBIx::Custom Documents >

Connect to SQLite by connect method.

my $dbi = DBIx::Custom->connect(
  dsn => "dbi:SQLite:dbname=$database",
  option => {sqlite_unicode => 1}
);

set dsn to data source name, and option to DBI options. Return value is DBIx::Custom object.

sqlite_unicode option set to 1, Perl internal string is automatically converted to UTF-8 byte string.

SQLite can connect to on-memory database for test.

my $dbi = DBIx::Custom->connect(
  dsn => "dbi:SQLite:dbname=:memory:"
);
Clone this wiki locally