SQLite.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Shortcut/sqlite.pm ↑ Summary SQLite/SQLMaker.pm »
1 package DBIO::SQLite;
2 # ABSTRACT: SQLite-specific schema management for DBIO
3 5 our $VERSION = '0.900001';
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 11 ▶sub connection {
Subroutine connection: called CC=1 SCAR=0.0
Pod documented
11 11 my ($self, @info) = @_;
12 11 $self->storage_type('+DBIO::SQLite::Storage');
13 11 return $self->next::method(@info);
14 }
15  
16 5 1;
17  
18 __END__
19  
20 =pod
21  
22 =encoding UTF-8
23  
24 =head1 NAME
25  
26 DBIO::SQLite - SQLite-specific schema management for DBIO
27  
28 =head1 VERSION
29  
30 version 0.900001
31  
32 =head1 SYNOPSIS
33  
34 =head2 Schema class
35  
36 package MyApp::Schema;
37 use DBIO Schema => -sqlite;
38  
39 The C<-sqlite> shortcut pins C<+DBIO::SQLite::Storage> as the storage type.
40 It is equivalent to the explicit component form:
41  
42 package MyApp::Schema;
43 use DBIO 'Schema';
44 __PACKAGE__->load_components('SQLite');
45  
46 =head2 Result classes
47  
48 package MyApp::Schema::Result::Artist;
49 use DBIO;
50  
51 __PACKAGE__->table('artist');
52 __PACKAGE__->add_columns(
53 id => { data_type => 'integer', is_auto_increment => 1 },
54 name => { data_type => 'varchar', size => 100 },
55 );
56 __PACKAGE__->set_primary_key('id');
57 __PACKAGE__->has_many(cds => 'MyApp::Schema::Result::CD', 'artist_id');
58  
59 package MyApp::Schema::Result::CD;
60 use DBIO;
61  
62 __PACKAGE__->table('cd');
63 __PACKAGE__->add_columns(
64 id => { data_type => 'integer', is_auto_increment => 1 },
65 artist_id => { data_type => 'integer' },
66 title => { data_type => 'varchar', size => 200 },
67 );
68 __PACKAGE__->set_primary_key('id');
69 __PACKAGE__->belongs_to(artist => 'MyApp::Schema::Result::Artist', 'artist_id');
70  
71 =head2 Connecting
72  
73 my $schema = MyApp::Schema->connect('dbi:SQLite:db/app.db');
74 $schema->deploy;
75  
76 my $artist = $schema->resultset('Artist')->create({ name => 'Sonic Youth' });
77 my @cds = $artist->cds->all;
78  
79 The classic C<use base> form is still supported:
80  
81 package MyApp::Schema;
82 use base 'DBIO::Schema';
83 __PACKAGE__->load_components('SQLite');
84  
85 =head1 DESCRIPTION
86  
87 L<DBIO::SQLite> is the SQLite driver component for DBIO.
88  
89 When this component is loaded into a schema class, C<connection()> sets
90 L<DBIO::Schema/storage_type> to C<+DBIO::SQLite::Storage>, which enables
91 SQLite-specific storage behavior automatically.
92  
93 =head1 METHODS
94  
95 =head2 connection
96  
97 Overrides L<DBIO/connection> to force C<+DBIO::SQLite::Storage> as
98 C<storage_type>.
99  
100 =head1 MIGRATION NOTES
101  
102 SQLite storage and SQLMaker classes were split out of the historical
103 DBIx::Class monolithic distribution:
104  
105 =over 4
106  
107 =item *
108  
109 Old: C<DBIx::Class::Storage::DBI::SQLite>
110  
111 =item *
112  
113 New: C<DBIO::SQLite::Storage>
114  
115 =item *
116  
117 Old: C<DBIx::Class::SQLMaker::SQLite>
118  
119 =item *
120  
121 New: C<DBIO::SQLite::SQLMaker>
122  
123 =back
124  
125 If C<DBIO-SQLite> is installed, core L<DBIO::Storage::DBI> can autodetect
126 SQLite DSNs and load the new storage class via the driver registry.
127  
128 =head1 TESTING
129  
130 SQLite tests in this distribution use in-memory databases and do not require
131 database credentials.
132  
133 Offline SQLMaker tests can use L<DBIO::SQLite::Test> or L<DBIO::Test> with:
134  
135 storage_type => 'DBIO::SQLite::Storage'
136  
137 Shared tests can also exercise the replicated path with:
138  
139 replicated => 1,
140 storage_type => 'DBIO::SQLite::Storage'
141  
142 =head1 AUTHOR
143  
144 DBIO & DBIx::Class Authors
145  
146 =head1 COPYRIGHT AND LICENSE
147  
148 Copyright (C) 2026 DBIO Authors
149 Portions Copyright (C) 2005-2025 DBIx::Class Authors
150 Based on DBIx::Class, heavily modified.
151  
152 This is free software; you can redistribute it and/or modify it under
153 the same terms as the Perl 5 programming language system itself.
154  
155 =cut
« Shortcut/sqlite.pm ↑ Summary SQLite/SQLMaker.pm »