IMDB::Local::DB - Direct access to IMDB::Local database.
Package to interact with the IMDB:Local Database.
my $DB=new IMDB::Local::DB(database=>"/home/user/imdbLocal-data/imdb.db");
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 the database. This must be called after new() and prior to connect().
Connect and auto-create the database.
The following functions are inherited from IMDB::Local::Base.
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.
Check to see if there has been previous successful 'connect' call.
Call quote subroutine on DBI handle. Quote must not be called while not connected.
Commit a DBI transaction (should only be used if db_AutoCommit was zero).
Retrieve the last inserted key for a given table and primaryKey.
Execute a sql statement and return 1 upon success and 0 upon success. Upon failure, carp() is called with the sql statement.
Return DBI->err() to retrieve error status of previous call to runSQL.
Return DBI->errstr() to retrieve error status of previous call to runSQL.
Return DBI->prepare() for a given statement.
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.
Execute a table insertion and return the created primaryKey (if specified). If primaryKey is not defined, 1 is returned upon success
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
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.
Check to see at least one row exists with value in 'column' in the specified 'table'
Execute the given sql statement and return the value in a single scalar value
Execute the given sql statement and return the value cast as an integer (ie int(returnvalue))
Execute the given sql statement and return an array with all the results.
Execute the given sql statement and return an array of arrays, each containing a row of values
Execute the given sql statement and return a reference to a hash with the result
Execute the given sql statement and return a reference ot a hash containing the given row.
Retrieve a list of tables available. Created Tables or Views created after connect() may not be included.
Check to see if a given table exists. Uses table_list.
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
Retrieve a list of column names in column_list order.
Run an sql query and output the result to the specified file in Text::CSV format
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.
Retrieve the # of rows in a given table.
Retrieve a reference to an array of arrays, each sub-array containing [table, #ofRows, data-size-in-KBs, index-size-in-KBs]
jerryv, <jerry.veldhuis at gmail.com>
<jerry.veldhuis at gmail.com>
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.
bug-imdb-local at rt.cpan.org
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
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:
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.
To install IMDB::Local, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.