NAME
DB::Object::SQLite::Tables - SQLite Table Object
SYNOPSIS
use DB::Object::SQLite::Tables;
my $this = DB::Object::SQLite::Tables->new || die( DB::Object::SQLite::Tables->error, "\n" );
VERSION
v1.0.0
DESCRIPTION
This is a SQLite table object class.
METHODS
create
This creates a table.
It takes some array reference data containing the columns definitions, some optional parameters and a statement handler.
If a statement handler is provided, then no need to provide an array reference of columns definition. The columns definition will be taken from the statement handler. However, at least either one of them needs to be provided to set the columns definition.
Possible parameters are:
comment
password
temporary
If provided, this will create a temporary table.
This will return an error if the table already exists, so best to check beforehand with "exists".
Upon success, it will return the new statement to create the table. However, if "create" is called in void context, then the statement is executed right away and returned.
create_info
This returns the create info for the current table object as a string representing the sql script necessary to recreate the table.
exists
Returns true if the current table exists, or false otherwise.
lock
Table lock is unsupported in SQLite and this will return an error.
on_conflict
A convenient wrapper to "on_conflict" in DB::Object::Postgres::Query
This feature is available in SQLite since version 3.35.0 released on 2021-03-12. If your version of SQLite is anterior, this will return an error.
rename
Provided with a new table name, and this will prepare the necessary query to rename the table and return the statement handler.
If it is called in void context, the statement handler is executed immediately.
# Get the prefs table object
my $tbl = $dbh->pref;
$tbl->rename( 'prefs' );
# Would issue a statement handler for the query: ALTER TABLE pref RENAME TO prefs
See SQLite documentation for more information
structure
This returns in list context an hash and in scalar context an hash reference of the table structure.
The hash, or hash reference returned contains the column name and its definition.
This method will also set the following object properties:
-
The table type.
default
A column name to default value hash reference
fields
A column name to field position (integer) hash reference
null
A column name to a boolean representing whether the column is nullable or not.
"primary" in DB::Object::Tables
An array reference of column names that are used as primary key for the table.
structure
A column name to its sql definition
types
A column name to column data type hash reference
table_info
This is an alias for "table_info" in DB::Object::SQLite
unlock
This returns an error as unlock
is unsupported in SQLite
SEE ALSO
AUTHOR
Jacques Deguest <jack@deguest.jp>
COPYRIGHT & LICENSE
Copyright (c) 2019-2021 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.