Class::DBI::Test::SQLite - Base class for Class::DBI tests
| Use Case | Command | Description |
|---|---|---|
| Inherit from the test base class | use base 'Class::DBI::Test::SQLite'; | Setup test class with SQLite backend |
| Define table name | __PACKAGE__->set_table('test'); | Create table and associate with class |
| Provide SQL schema | sub create_sql { ... } | Return table creation SQL as string |
| Define columns | __PACKAGE__->columns(All => qw/id name film salary/); | Set column list for Class::DBI |
use base 'Class::DBI::Test::SQLite';
__PACKAGE__->set_table('test');
__PACKAGE__->columns(All => qw/id name film salary/);
sub create_sql {
return q{
id INTEGER PRIMARY KEY,
name CHAR(40),
film VARCHAR(255),
salary INT
}
}
This provides a simple base class for Class::DBI tests using SQLite. Each class for the test should inherit from this, provide a create_sql() method which returns a string representing the SQL used to create the table for the class, and then call set_table() to create the table, and tie it to the class.
__PACKAGE__->set_table('test');
This combines creating the table with the normal Class::DBI table() call.
sub create_sql {
return q{
id INTEGER PRIMARY KEY,
name CHAR(40),
film VARCHAR(255),
salary INT
}
}
This should return, as a text string, the schema for the table represented by this class.
perl v5.32.0 2020-12-28 Class::DBI::Test::SQLite(3pm)
Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-21 06:21 @2600:1f28:365:80b0:e9a9:ac35:f5fe:ea62
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format