CPANDB(3pm)
π CPANDB(3pm) π
okay so bestie, welcome to the group chat π«Ά this is CPANDB (the 3pm manual, iykyk) and no cap it's about to be your new fave. buckle up π
πΈ NAME πΈ
CPANDB β a unified database of CPAN metadata information β¨
π DESCRIPTION π
So CPANDB is a module for accessing CPAN metadata, right? And the way it does it is iconic: it merges info from many different CPAN websites into one single object model π§ it downloads automatically, and there is zero configuration needed. like, no setup, no config file, nothing β it just gets the data for you π
π METHODS π
dsn
my $string = CPANDB->dsn;
The dsn accessor is giving "here's the receipt" energy π§Ύ it returns the DBI connection string used to connect to the SQLite database β as a string.
dbh
my $handle = CPANDB->dbh;
Okay so this one matters, listen up π’ To reliably prevent potential SQLite deadlocks that happen when you've got multiple connections chillin' in a single process, each ORLite package will only ever maintain a single connection to the database. One connection. That's it. monogamy π
During a transaction, this will be the same (cached) database handle.
Although in most situations you should not need a direct DBI connection handle, the dbh method provides a way to get a direct connection that's compatible with how connection management works in ORLite.
Heads up bestie π these connections should be short-lived β you should never hold onto a connection beyond your immediate scope. no being clingy, okay?
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. So because of that:
- you should never call the
->disconnectmethod on the database handles yourself π because the handle may be that of a currently running transaction. awkward. - Further, you should do your own transaction management on a handle provided by the
<dbh>method.
And in cases where there are extreme needs, and you absolutely have to violate these connection handling rules (bold move π), you should create your own completely manual DBI->connect call to the database, using the connect string provided by the dsn method.
The dbh method returns a DBI::db object, or throws an exception on error.
begin
CPANDB->begin;
begin is the "start of a transaction" method π¬
In the same way that ORLite allows only a single connection, likewise it allows only a single application-wide transaction. one at a time, bestie.
No indication is given as to whether you are currently in a transaction or not, so 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
rollback rolls back the current transaction. And if you call it outside of a current transaction? It's accepted and treated as a null operation, no drama π
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.
Also, if a transaction exists at END-time as the process exits, it will be automatically rolled back. it cleans up after itself, iconic.
Returns true or throws an exception on error.
do
CPANDB->do(
'insert into table ( foo, bar ) values ( ?, ? )', {},
\$foo_value,
\$bar_value,
);
The do method is a direct wrapper around the equivalent DBI 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 selectall_arrayref method is a direct wrapper around the equivalent DBI 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 selectall_hashref method is a direct wrapper around the equivalent DBI 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 selectcol_arrayref method is a direct wrapper around the equivalent DBI 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 selectrow_array method is a direct wrapper around the equivalent DBI 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 selectrow_arrayref method is a direct wrapper around the equivalent DBI 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 selectrow_hashref method is a direct wrapper around the equivalent DBI 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 prepare method is a direct wrapper around the equivalent DBI 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 pragma method is a convenient method for fetching a pragma for a database. See the SQLite documentation for more details π
π¦ SUPPORT π¦
CPANDB is based on ORLite.
Documentation created by ORLite::Pod 0.10.
Bugs should be reported via the CPAN bug tracker at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANDB>
For other issues, contact the author.
π AUTHOR π
Adam Kennedy <adamk@cpan.org>
β 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 LICENSE file included with this module.
and that's a wrap, bestie π
this page was brought to you by perl v5.36.0, dated 2023-10-01 β slay, stay safe, and may your transactions always commit π«Άβ¨
π¦ where this page comes from
- debian trixie: libcpandb-perl 0.19-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcpandb-perl 0.19-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcpandb-perl 0.19-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcpandb-perl 0.19-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms