The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

LARC::DB - Provides a methode for storing SQLite DBs in a pleasantly organized manner.

VERSION

Version 0.0.0

SYNOPSIS

use LARC::DB;

my $ldb = LARC::DB->new();

FUNCTIONS

new

Initializes the module. No arguements are taken. No arguements are required.

my $ldb = LARC::DB->new();

connect

This generates to a SQLite DB connecting and returns a DBI object.

my $dbh=$ldb->connect('some/DB');
if($ldb->{error}){
    print "ERROR!";
}

DBexists

Checks if a database exists or not. One one option is accepted and that is the DB name.

my $returned=$ldb->DBexists('foo/bar');
if($ldb->{error}){
    print 'Error:'.$ldb->{error}.':'.$error->{errorString};
}
if($returned){
    print 'It exists';
}

init

This initiliazes the support stuff for it all. It currently just creates '~/larc/DB/' if needed.

$ldb->init();
if($ldb->{error}){
    print "ERROR!";
}

list

List DBs under a specific path. The returned value is an array.

Any thing ending in '/' is a directory. If something is both a directory and DB, both an entry for the DB and directory is listed.

Any thing beginning with an '.' is not returned.

my @DBs=$ldb->list('some/');
if($ldb->{error}){
    print "ERROR!";
}

newdb

Creates a new DB.

$ldb->newdb('some/DB');
if($ldb->{error}){
    print "ERROR!";
}

rmdb

Removes a DB.

$ldb->rmdb('some/DB');
if($ldb->{error}){
    print "ERROR!";
}

validname

This checks if a DB name is valid or not.

if($returned=$ldb->validname('some/DB')){
    print 'Invalid name'.
}

errorBlank

This blanks the error storage and is only meant for internal usage.

It does the following.

$self->{error}=undef;
$self->{errorString}="";

STORAGE

The base dir used is '$ENV{HOME}/larc/DB/'. The specified DB is then tacked onto that as a path with '.sqlite' appended to the end. So the DB 'foo/bar' then becomes '$ENV{HOME}/larc/DB/foo/bar.sqlite'. This allows a DB to have sub DBs in regards to how the path looks.

A DB may not begin with '.' or have that any were after an '/'. Thus the following are all invalid.

./someDB
some/.DB
some/.something/DB

ERROR CODES

1

The base directory, '~/larc/DB/', does exists, but is not a directory.

2

The enviromental variable 'HOME' is not defined.

3

Failed to create the directory '~/larc' or '~/larc/DB';

4

The database does not exist.

5

Failed to create the new SQLite file.

6

The DB already exists.

7

Reservered for future use.

8

Failed to unlink a DB file.

9

Failed to remove the specified directory.

10

Mkpath failed.

11

The specified DB is not also a directory.

12

Invalid DB name.

13

Opendir error.

AUTHOR

Zane C. Bowers, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-larc-db at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LARC-DB. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc LARC::DB

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Zane C. Bowers, all rights reserved.

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