Test::SQLite - SQLite setup/teardown for tests
version 0.0207
use DBI; use Test::SQLite; my $sqlite = Test::SQLite->new(database => '/some/where/production.db'); my $dbh = $sqlite->dbh; $sqlite = Test::SQLite->new( schema => '/some/where/schema.sql', db_attrs => { RaiseError => 1, AutoCommit => 0 }, ); $dbh = DBI->connect($sqlite->dsn, '', '', $sqlite->db_attrs);
Test::SQLite is loosely inspired by Test::PostgreSQL and Test::mysqld, and creates a temporary db to use in tests. Unlike those modules, it is limited to setup/teardown of the test db given a database or schema SQL file. Also this module will return the database dbh handle and dsn connection string.
Test::SQLite
The database to copy.
Boolean indicating that a database file was provided to the constructor.
The SQL schema with which to create a test database.
* The SQL parsing done by this module does not handle triggers.
Boolean indicating that a schema file was provided to the constructor.
DBI connection attributes. Default: { RaiseError => 1, AutoCommit => 1 }
The database connection string.
A connected database handle based on the dsn and db_attrs.
$sqlite = Test::SQLite->new(%arguments);
Create a new Test::SQLite object, which creates a temporary database given a database or schema.
Ensure that we are given either a database or a schema and not both.
The t/01-methods.t file in this distribution.
DBI
File::Copy
File::Temp
Moo
Kaitlyn Parkhurst <symkat@symkat.com>
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2020 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::SQLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::SQLite
CPAN shell
perl -MCPAN -e shell install Test::SQLite
For more information on module installation, please visit the detailed CPAN module installation guide.