The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQLite::DB provides an object oriented wrapper to SQLite databases using DBI and DBD::SQLite modules.

SYNOPSIS

 use SQLite::DB;

 my $db = SQLite::DB->new('file');

 $db->connect;

 $db->select("select * from table where field = value",{}) || print $db->get_error."\n";

 $db->select("select * from table where field = ?",{},"value") || print $db->get_error."\n";

 $result = $db->select_one_row("select max(field) as total FROM table");

 print $$result{TOTAL};

 $db->transaction_mode;

 $db->exec("INSERT (a,b,c) VALUES 'a','b','c'");
 $db->exec("INSERT (a,b,c) VALUES ?,?,?",'a','b','c');
 $db->exec("update table set field = value") || print $db->get_error."\n";

 $db->commit || print $db->get_error."\n";
 $db->rollback || print $db->get_error."\n";

 my $resultset = $db->get_dblist("select * from table","display_field","keyfield");

 if (!ref $resultset) {
   print $db->get_error."\n"
 } else {
   for (@$resultset) {
     print $resultset->[$_]->{id}." - ".$resultset->[$_]->{value}."\n";
   }
 }

 $db->disconnect;

DESCRIPTION

The goal is provide simple coding style to interact with SQLite databases.

CLASSES

SQLite::DB

USE

DBI, DBD:SQLite

CLASS METHODS

new($path)

Construtor. $path is the full path to the db file.

connect

Connect to the database. If it does not exists, it created an new database.

disconnect

Disconnect to the database.

transaction_mode

Define transaction mode. No commits will be done until get the commit function.

commit

Commit an transaction. If is not in transaction mode, nothing happens.

rollback

Rollback an transaction. If is not in transaction mode, nothing happens.

exec($query,[@args...])

Execute an query. Optional argumens are used when you want to bind params of your query.

select($query,$funcptr,[@args...])

Execute an select query.

$funcptr is an callback function pointer that received $sth object as argument, to process the rows of the select query.

Optional argumens are used when you want to bind params of your query.

select_one_row($query)

Provides an easier way to retrieve one row queries. It returns an hash with field/values of the query.

get_dblist($query,$display_field,$keyfield)

Provided an easier way to retrive two columns queries.

It returns an array with hash itens with "id" and "value" itens.

get_error

Return last error.

$head2 get_affected_rows

Return the number of affected rows from the last exec query.

INTERNAL METHODS

  • check_error

    This method provide an common way to check DBI/DBD errors.

  • get_sql_type

    This returns the type of an query.

EXPORT

$item * last_insert_rowid

Stores the last insert rowid.

KNOWN BUGS

None.

AUTHOR

Vitor Serra Mori <vvvv767@hotmail.com.>

COPYRIGHT

This package is free software. Tou can redistribute and/or modify it under the same terms as Perl itself.

# }}}

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 436:

=back without =over

Around line 440:

'=item' outside of any '=over'

Around line 448:

You forgot a '=back' before '=head1'