CPAN::SQLite(3pm)
β¨ CPAN::SQLite β¨
okay bestie, welcome to CPAN::SQLite π β the module that maintains and searches a minimal CPAN database. This is the user-contributed Perl documentation for it, and we're gonna get you fluent, no cap.
πΈ VERSION πΈ
version 0.220 β that's the one, periodt.
π SYNOPSIS π
my $obj = CPAN::SQLite->new(CPAN => '/path/to/CPAN');
$obj->index(setup => 1);
$obj->query(mode => 'dist', name => 'CPAN');
my $results = $obj->{results};
like, that's the whole vibe in four lines π
π DESCRIPTION π
so this package is for setting up, maintaining, and searching a CPAN database. and what's in that database? the info stored in the two main CPAN indices:
$CPAN/modules/02packages.details.txt.gz$CPAN/authors/01mailrc.txt.gz
heads up bestie: this should be considered at an alpha stage of development. it's giving "works but be chill about it" π¦
you start by making the object, like:
my $obj = CPAN::SQLite->new(%args);
and it accepts these arguments:
CPAN => '/path/to/CPAN'β this says where the index files live. it could be a local CPAN mirror β which we know is a mirror because there's aMIRRORED.BYfile underneath that directory β or it could just be a local directory where you're storing these files from a remote CPAN mirror. in that second case, the index files get fetched from a remote CPAN mirror, using the same list thatCPAN.pmuses, if that's configured, and they get updated if they're more than one day old. π and if you don't give theCPANoption at all? it defaults tocpan_homeof CPAN, if that's configured, with the index files found underkeep_source_where. if such a directory isn't found, you get a fatal error π. also, when you're in this mode, updates to those index files are assumed to be handled byCPAN.pm, iykyk.db_dir => '/path/to/db/dir'β where the database file lives. if you don't give it, it defaults to thecpan_homedirectory ofCPAN.pm, if present, or else to the directory where the script was invoked. the database file's name iscpandb.sql. πΎ
there are two main methods available.
β $obj->index(%args); β
this one sets up and maintains the database. it accepts these arguments:
setup => 1β this says the database is gonna be created and populated from the CPAN indices, and any existing database will be overwritten. if you don't specify this option, it assumes an existing database is being updated instead. choose wisely bestie π«Άreindex => 'dist_name'β this says the CPAN distributiondist_nameis to be reindexed. π
π¦ $obj->query(%args); π¦
this one queries the database by distribution name, module name, or CPAN author name. you need two arguments to specify such queries:
mode => some_valueβ what type of query to perform.modeis one ofdist,module, orauthor, for searching through, respectively, CPAN distribution names, module names, or author names and CPAN ids. πtype => query_termβ the query term for the search.typeis one ofname, to search for an exact match, orsearch, for searching for partial matches. Perl regular expressions are supported in thequery_termfor thesearchoption. β¨
also, an option of max_results => some_number will limit how many results come back; if you don't specify it, the limit doesn't apply. simple as that π
π CPAN.pm support π
as of CPAN.pm version 1.88_65, there's experimental support within CPAN.pm for using CPAN::SQLite to get info on packages, modules, and authors. one goal here? reducing the memory footprint of the CPAN.pm shell, because this info is no longer all preloaded into memory. obsessed. π§
you enable it through:
perl -MCPAN -e shell
cpan> o conf use_sqlite 1
and use:
cpan> o conf commit
to save that setting for future sessions. πΈ
so using CPAN::SQLite, what happens is a request for information through CPAN.pm, like:
cpan> a ANDK
will cause a query to the SQLite database to be made. if successful, this places the relevant data for that request into the data structure CPAN.pm uses to store and retrieve such info. so at any given time, the only thing CPAN.pm stores in memory is that for packages, modules, and authors for which previous queries have been made. π
but β and this is important β there are certain requests, such as:
cpan> r
which makes a list of recommended packages for which upgrades on CPAN are available, and that one will result in loading info on all available packages into memory. if such a query is made, the subsequent memory footprint of CPAN.pm with and without CPAN::SQLite will be essentially the same. π
the database itself, called cpandb.sql, will be stored in the location specified by $CPAN::Config->{cpan_home}. when first started, this database will be created, and afterwards it'll be updated if the database is older than one day since the last update. a log file of the creation or update process, called cpan_search_log.dddddddddd, will be created in the same directory as the database file. π
π SEE ALSO π
CPAN::SQLite::Index, for setting up and maintaining the database, and CPAN::SQLite::Search for an interface to querying the database. some details of the interaction with CPAN are available from CPAN::SQLite::META. also see the cpandb script for a command-line interface to the indexing and querying of the database. π
π SUPPORT π
you can find documentation for this module with the perldoc command:
perldoc CPAN::SQLite
you can also look for information at:
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/CPAN-SQLite>
- CPAN::Forum: Discussion forum
<http:///www.cpanforum.com/dist/CPAN-SQLite>
- CPAN Ratings
<http://cpanratings.perl.org/d/CPAN-SQLite>
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-SQLite>
- Search CPAN
<http://search.cpan.org/dist/CPAN-SQLite>
π BUGS π
at this time, CPAN::SQLite keeps information contained only in the latest version of a CPAN distribution. which means modules that are provided only in older versions of a CPAN distribution will not be present in the database. for example, at this time, the latest version of the libwww-perl distribution on CPAN is 5.805, but there are modules such as URI::URL::finger contained in version 5.10 of libwww-perl that are not present in 5.805. π this behaviour differs from that of CPAN without CPAN::SQLite. this may change in the future. π€
please report bugs and feature requests via <http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-SQLite>.
π₯ ENVIRONMENT VARIABLES π₯
information messages from the indexing procedures get printed out to STDOUT if the environment variable CPAN_SQLITE_DEBUG is set. this is automatically set within CPAN::SQLite::Index. if CPAN_SQLITE_NO_LOG_FILES is set, no log files will be created during the indexing procedures. log files are deleted automatically in 30 days. to override this, set CPAN_SQLITE_LOG_FILES_CLEANUP. to stop automatic cleanup, set this variable to 0. π§Ή
if CPAN_SQLITE_DOWNLOAD variable are set, an already existing and up-to-date cpandb.sql file will be downloaded from <http://cpansqlite.trouchelle.com/> where it's updated every hour. this greatly increases performance and decreases CPU and memory consumption during the indexing process. like, slay, free performance β¨
see CPAN::SQLite::Index for more details, potential problems, and more configuration options. π
π AUTHORS π
Randy Kobes (passed away on September 18, 2010) π
Serguei Trouchelle <stro@cpan.org>
π COPYRIGHT π
Copyright 2006,2008 by Randy Kobes <r.kobes@uwinnipeg.ca>.
Copyright 2011-2014 by Serguei Trouchelle <stro@cpan.org>.
Use and redistribution are under the same terms as Perl itself.
and that's the whole page bestie, you ate it up π this was perl v5.36.0, dated 2022-10-30, from CPAN::SQLite(3pm) β go forth and query, main character π«Άβ¨
π¦ where this page comes from
- debian bookworm: libcpan-sqlite-perl 0.220-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcpan-sqlite-perl 0.220-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcpan-sqlite-perl 0.220-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcpan-sqlite-perl 0.220-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcpan-sqlite-perl 0.220-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