NAME

DBIO::SQLite::Storage - SQLite storage driver for DBIO

VERSION

version 0.900000

DESCRIPTION

SQLite storage driver for DBIO. Extends DBIO::Storage::DBI with SQLite-specific behavior including savepoint support, foreign key pragma helpers, database file backup, and workarounds for known DBD::SQLite bugs.

This class is registered as the driver for SQLite and is loaded automatically when connecting to a SQLite DSN. It uses DBIO::SQLite::SQLMaker for SQL generation, LimitOffset pagination, double-quote identifiers, and DateTime::Format::SQLite for datetime parsing.

METHODS

_dbh_columns_info_for

Override the parent's column_info lookup. DBD::SQLite does not implement NULLABLE correctly -- PRIMARY KEY columns and columns constrained by UNIQUE ... NOT NULL come back as nullable. This override layers the truth from PRAGMA table_info (notnull) on top of the parent method's result so that is_nullable is correct for downstream consumers like "columns_info_for" in DBIO::Result.

backup

my $backupfile = $storage->backup($dir);
my $backupfile = $storage->backup;          # defaults to './'

Copy the live SQLite database file to $dir. The backup filename includes a timestamp prefix. Returns the full path to the backup file.

Throws an exception if the database filename cannot be determined from the DSN or if the file copy fails.

bind_attribute_by_data_type

Returns DBI::SQL_BIGINT for any integer-family column type (int, integer, tinyint, smallint, mediumint, bigint, int1, int2, int4, int8). Returns undef for all other types, deferring to the default binding behavior.

SQLite stores all numeric values as dynamically-sized integers up to 8 bytes, so binding everything as SQL_BIGINT is safe and avoids unnecessary type coercions.

with_deferred_fk_checks

$storage->with_deferred_fk_checks(sub { ... });

Execute $sub inside a transaction with PRAGMA defer_foreign_keys = ON. Foreign key constraint checking is deferred until the transaction commits, allowing bulk inserts or other operations that temporarily violate referential integrity within the same transaction. The transaction is committed automatically after $sub returns.

connect_call_use_foreign_keys

A connect-time callback that executes PRAGMA foreign_keys = ON. SQLite does not enforce foreign key constraints by default. Enable it by passing on_connect_call => 'use_foreign_keys' in your connection options:

$schema->connect(
    'dbi:SQLite:db/app.db', '', '',
    { on_connect_call => 'use_foreign_keys' },
);

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 470:

Unknown directive: =seealso