DBD-SQLite2
view release on metacpan or search on metacpan
lib/DBD/SQLite2.pm view on Meta::CPAN
Rather than ask you to install SQLite first, because SQLite is public
domain, DBD::SQLite2 includes the entire thing in the distribution. So
in order to get a fast transaction capable RDBMS working for your
perl project you simply have to install this module, and B<nothing>
else.
For real work please use the updated L<DBD::SQLite> driver with the
up-to-date sqlite3 backend.
SQLite2 supports the following features:
=over 4
=item Implements a large subset of SQL92
See http://www.sqlite.org/lang.html for details.
=item A complete DB in a single disk file
Everything for your database is stored in a single disk file, making it
easier to move things around than with L<DBD::CSV>.
=item Atomic commit and rollback
Yes, DBD::SQLite2 is small and light, but it supports full transactions
=item Extensible
User-defined aggregate or regular functions can be registered with the
SQL parser.
=back
There's lots more to it, so please refer to the docs on the SQLite web
page, listed above, for SQL details. Also refer to L<DBI> for details
on how to use DBI itself.
=head1 CONFORMANCE WITH DBI SPECIFICATION
The API works like every DBI module does. Please see L<DBI> for more
details about core features.
Currently many statement attributes are not implemented or are
limited by the typeless nature of the SQLite2 database.
=head1 DRIVER PRIVATE ATTRIBUTES
=head2 Database Handle Attributes
=over 4
=item sqlite_version
Returns the version of the SQLite library which DBD::SQLite2 is using, i.e, "2.8.15".
=item sqlite_encoding
Returns either "UTF-8" or "iso8859" to indicate how the SQLite library was compiled.
=item sqlite_handle_binary_nulls
Set this attribute to 1 to transparently handle binary nulls in quoted
and returned data.
B<NOTE:> This will cause all backslash characters (C<\>) to be doubled
up in all columns regardless of whether or not they contain binary
data or not. This may break your database if you use it from another
application. This does not use the built in C<sqlite_encode_binary>
and C<sqlite_decode_binary> functions, which may be considered a bug.
=back
=head1 DRIVER PRIVATE METHODS
=head2 $dbh->func('last_insert_rowid')
This method returns the last inserted rowid. If you specify an INTEGER PRIMARY
KEY as the first column in your table, that is the column that is returned.
Otherwise, it is the hidden ROWID column. See the sqlite docs for details.
=head2 $dbh->func( $name, $argc, $func_ref, "create_function" )
This method will register a new function which will be useable in SQL
query. The method's parameters are:
=over
=item $name
The name of the function. This is the name of the function as it will
be used from SQL.
=item $argc
The number of arguments taken by the function. If this number is -1,
the function can take any number of arguments.
=item $func_ref
This should be a reference to the function's implementation.
=back
For example, here is how to define a now() function which returns the
current number of seconds since the epoch:
$dbh->func( 'now', 0, sub { return time }, 'create_function' );
After this, it could be use from SQL as:
INSERT INTO mytable ( now() );
=head2 $dbh->func( $name, $argc, $pkg, 'create_aggregate' )
This method will register a new aggregate function which can then used
from SQL. The method's parameters are:
=over
=item $name
The name of the aggregate function, this is the name under which the
( run in 0.939 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )