DESCRIPTION

\s-1CPANDB\s0 is an module for accessing \s-1CPAN\s0 metadata merged from many different \s-1CPAN\s0 websites into a single object model, downloaded automatically and without the need for any configuration.

METHODS

dsn

  my $string = CPANDB->dsn;

The \*(C`dsn\*(C' accessor returns the \s-1DBI\s0 connection string used to connect to the SQLite database as a string.

dbh

my $handle = CPANDB->dbh;

To reliably prevent potential SQLite deadlocks resulting from multiple connections in a single process, each ORLite package will only ever maintain a single connection to the database.

During a transaction, this will be the same (cached) database handle.

Although in most situations you should not need a direct \s-1DBI\s0 connection handle, the \*(C`dbh\*(C' method provides a method for getting a direct connection in a way that is compatible with connection management in ORLite.

Please note that these connections should be short-lived, you should never hold onto a connection beyond your immediate scope.

The transaction system in ORLite is specifically designed so that code using the database should never have to know whether or not it is in a transation.

Because of this, you should never call the ->disconnect method on the database handles yourself, as the handle may be that of a currently running transaction.

Further, you should do your own transaction management on a handle provided by the <dbh> method.

In cases where there are extreme needs, and you absolutely have to violate these connection handling rules, you should create your own completely manual \s-1DBI-\s0>connect call to the database, using the connect string provided by the \*(C`dsn\*(C' method.

The \*(C`dbh\*(C' method returns a DBI::db object, or throws an exception on error.

begin

CPANDB->begin;

The \*(C`begin\*(C' method indicates the start of a transaction.

In the same way that ORLite allows only a single connection, likewise it allows only a single application-wide transaction.

No indication is given as to whether you are currently in a transaction or not, all code should be written neutrally so that it works either way or doesn't need to care.

Returns true or throws an exception on error.

rollback

The \*(C`rollback\*(C' method rolls back the current transaction. If called outside of a current transaction, it is accepted and treated as a null operation.

Once the rollback has been completed, the database connection falls back into auto-commit state. If you wish to immediately start another transaction, you will need to issue a separate ->begin call.

If a transaction exists at END-time as the process exits, it will be automatically rolled back.

Returns true or throws an exception on error.

do

CPANDB->do( 'insert into table ( foo, bar ) values ( ?, ? )', {}, \$foo_value, \$bar_value, );

The \*(C`do\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectall_arrayref

The \*(C`selectall_arrayref\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectall_hashref

The \*(C`selectall_hashref\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectcol_arrayref

The \*(C`selectcol_arrayref\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectrow_array

The \*(C`selectrow_array\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectrow_arrayref

The \*(C`selectrow_arrayref\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

selectrow_hashref

The \*(C`selectrow_hashref\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction.

It takes the same parameters and has the same return values and error behaviour.

prepare

The \*(C`prepare\*(C' method is a direct wrapper around the equivalent \s-1DBI\s0 method, but applied to the appropriate locally-provided connection or transaction

It takes the same parameters and has the same return values and error behaviour.

In general though, you should try to avoid the use of your own prepared statements if possible, although this is only a recommendation and by no means prohibited.

pragma

# Get the user_version for the schema my $version = CPANDB->pragma('user_version');

The \*(C`pragma\*(C' method provides a convenient method for fetching a pragma for a database. See the SQLite documentation for more details.

SUPPORT

\s-1CPANDB\s0 is based on ORLite.

Documentation created by ORLite::Pod 0.10.

Bugs should be reported via the \s-1CPAN\s0 bug tracker at

<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANDB>

For other issues, contact the author.

AUTHOR

Adam Kennedy <[email protected]>

COPYRIGHT

Copyright 2009 - 2012 Adam Kennedy.

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

The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.