DBIO-SQLite
view release on metacpan or search on metacpan
share/skills/dbio-sqlite-database/SKILL.md view on Meta::CPAN
allowed-tools: Read, Grep, Glob
model: sonnet
---
SQLite knowledge for Perl DB driver development.
## DBD::SQLite
- Bundles SQLite â no external dep
- In-memory: `dbi:SQLite:dbname=:memory:`
- `sqlite_unicode => 1` â enable UTF-8
- Connections NOT shareable across threads
## Type Affinity (advisory, not enforced)
| Affinity | Trigger | Examples |
|----------|---------|----------|
| INTEGER | contains "INT" | INTEGER, BIGINT, SMALLINT |
| TEXT | contains "CHAR", "CLOB", "TEXT" | VARCHAR(255), TEXT |
| BLOB | "BLOB" or empty | BLOB |
| REAL | contains "REAL", "FLOA", "DOUB" | REAL, DOUBLE, FLOAT |
share/skills/dbio-sqlite/SKILL.md view on Meta::CPAN
__PACKAGE__->load_components('SQLite');
__PACKAGE__->connect("dbi:SQLite:dbname=myapp.db");
```
In-memory: `dbi:SQLite:dbname=:memory:`
## Storage Setup
```perl
__PACKAGE__->connection("dbi:SQLite:dbname=:memory:", "", "", {
sqlite_unicode => 1,
});
```
## FK Enforcement
NOT enabled by default. Enable per-connection:
```perl
$dbh->do("PRAGMA foreign_keys = ON");
```
t/52leaks.t view on Meta::CPAN
my $obj = CORE::bless(
$_[0], (@_ > 1) ? $_[1] : do {
my ($class, $fn, $line) = caller();
fail ("bless() of $_[0] into $class without explicit class specification at $fn line $line")
if $class =~ /^ (?: DBIx\:\:Class | DBIO::Test ) /x;
$class;
}
);
# unicode is tricky, and now we happen to invoke it early via a
# regex in connection()
return $obj if (ref $obj) =~ /^utf8/;
# Test Builder is now making a new object for every pass/fail (que bloat?)
# and as such we can't really store any of its objects (since it will
# re-populate the registry while checking it, ewwww!)
return $obj if (ref $obj) =~ /^TB2::|^Test::Stream/;
# populate immediately to avoid weird side effects
return populate_weakregistry ($weak_registry, $obj );
t/debug/core.t view on Meta::CPAN
$_;
} finally {
# restore STDERR
close STDERR;
open(STDERR, '>&STDERRCOPY');
};
die "How did that fail... $exception"
if $exception;
is_deeply(\@warnings, [], 'No warnings with unicode on STDERR');
# test debugcb and debugobj protocol
{
my $rs = $schema->resultset('CD')->search( {
artist => 1,
cdid => { -between => [ 1, 3 ] },
title => { '!=' => \[ '?', undef ] }
});
my $sql_trace = 'SELECT "me"."cdid", "me"."artist", "me"."title", "me"."year", "me"."genreid", "me"."single_track" FROM cd "me" WHERE ( "artist" = ? AND ( "cdid" BETWEEN ? AND ? ) AND "title" != ? )';
t/resultset/rowparser_internals.t view on Meta::CPAN
$#{$_[0]} = $result_pos - 1;
',
'Multiple has_many on multiple branches with underdefined root, HRI-direct torture test',
);
done_testing;
my $deparser;
sub is_same_src { SKIP: {
skip "Skipping comparison of unicode-posioned source", 1
if stresstest_utf8_upgrade_generated_collapser_source;
$deparser ||= B::Deparse->new;
local $Test::Builder::Level = $Test::Builder::Level + 1;
my ($got, $expect) = @_;
skip "Not testing equality of source containing defined-or operator on this perl $]", 1
if ($] < 5.010 and$expect =~ m!\Q//=!);
( run in 0.629 second using v1.01-cache-2.11-cpan-9581c071862 )