NAME

IMDB::Local::DB - Direct access to IMDB::Local database.

VERSION

Version 0.01

SYNOPSIS

Package to interact with the IMDB:Local Database.

use IMDB::Local::DB;

my $DB=new IMDB::Local::DB(database=>"/home/user/imdbLocal-data/imdb.db");
...

SUBROUTINES/METHODS

new

This package extends Class::MethodMaker (making use of the -hash new option)

db_AutoCommit - scalar - default is 0, if set database
driver - scalar - default "SQLite" (currently only support dbi driver)
database - scalar - default "imdb.db" - relative path to IMDB::Local database 

Modifying any options after new() is not supported and unexpected results may occur.

delete

Delete the database. This must be called after new() and prior to connect().

connect

Connect and auto-create the database.

INHERITED FUNCTIONS

The following functions are inherited from IMDB::Local::Base.

disconnect

Disconnect from the database. Note that for those lazy programmers that fail to call disconnect, the disconnect will be called when the object is destructed through perl's DESTROY.

isConnected

Check to see if there has been previous successful 'connect' call.

quote

Call quote subroutine on DBI handle. Quote must not be called while not connected.

commit

Commit a DBI transaction (should only be used if db_AutoCommit was zero).

last_inserted_key

Retrieve the last inserted key for a given table and primaryKey.

runSQL

Execute a sql statement and return 1 upon success and 0 upon success. Upon failure, carp() is called with the sql statement.

runSQL_err

Return DBI->err() to retrieve error status of previous call to runSQL.

runSQL_errstr

Return DBI->errstr() to retrieve error status of previous call to runSQL.

prepare

Return DBI->prepare() for a given statement.

execute

Wrapper for calling DBI->prepare() and DBI->exeute() fora given query. Upon success the DBI->prepare() handle is returned. Upon failure, warn() is called with the query statement string and undef is returned.

insert_row

Execute a table insertion and return the created primaryKey (if specified). If primaryKey is not defined, 1 is returned upon success

query2SQLStatement

Construct an sql query using a hash containing:

fields - required array of fields to select
tables - required array of tables to select from
wheres - optional array of where clauses to include (all and'd together)
groupbys - optional array of group by clauses to include
sortByField - optional field to sort by (if prefixed with -, then sort is reversed)
orderbys - optional array of order by clauses to include
offset - offset of returned rows
limit - optional integer value to limit # of returned rows

findRecords

Call query2SQLStatement with the given hash arguments and return a IMDB::Local::DB::RecordIterator handle.

In addition to the query2SQLStatement arguments the following are optional: cacheBy - set cacheBy value in returned IMDB::Local::DB::RecordIterator handle. If not specified, limit is used.

rowExists

Check to see at least one row exists with value in 'column' in the specified 'table'

select2Scalar

Execute the given sql statement and return the value in a single scalar value

select2Int

Execute the given sql statement and return the value cast as an integer (ie int(returnvalue))

select2Array

Execute the given sql statement and return an array with all the results.

select2Matrix

Execute the given sql statement and return an array of arrays, each containing a row of values

select2HashRef

Execute the given sql statement and return a reference to a hash with the result

select2Hash

Execute the given sql statement and return a reference ot a hash containing the given row.

table_list

Retrieve a list of tables available. Created Tables or Views created after connect() may not be included.

table_exists

Check to see if a given table exists. Uses table_list.

column_info

Retrieve information about a given column in a table. Changes to columns made after connect() may not be included.

Returns a list of columns in a database/driver specific order containing: COLUMN_NAME - name of the column TYPE_NAME - data type (if available) COLUMN_SIZE - size of column data (if available) IS_NULL - true/false if column is nullable IS_PRIMARY_KEY - 1 or 0 if column is a primary key

column_list

Retrieve a list of column names in column_list order.

writeQuery2CSV

Run an sql query and output the result to the specified file in Text::CSV format

appendCSV2Table

Parse the given CVS file (which must have column names that match a the given table) and insert each row as a new row into the specified table.

Upon success, returns > 0, number of rows successfully inserted. Returns 0 if open() on the given file fails.

table_row_count

Retrieve the # of rows in a given table.

table_report

Retrieve a reference to an array of arrays, each sub-array containing [table, #ofRows, data-size-in-KBs, index-size-in-KBs]

AUTHOR

jerryv, <jerry.veldhuis at gmail.com>

BUGS

Please report any bugs or feature requests to bug-imdb-local at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IMDB-Local. 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 IMDB::Local::DB

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2015 jerryv.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.