DBIx::Sunny - Simple DBI wrapper
use DBIx::Sunny; my $dbh = DBIx::Sunny->connect(...); # or use DBI; my $dbh = DBI->connect(.., { RootClass => 'DBIx::Sunny', PrintError => 0, RaiseError => 1, });
DBIx::Sunny is a simple DBI wrapper. It provides better usability for you. This module based on Amon2::DBI. DBIx::Sunny supports only SQLite and MySQL.
DBIx::Sunny sets AutoInactiveDestroy as true.
DBIx::Sunny sets sqlite_unicode, mysql_enable_utf8 and pg_enable_utf8 automatically.
DBIx::Sunny sets sqlite_use_immediate_transaction to true, and executes these PRAGMA statements
PRAGMA journal_mode = WAL PRAGMA synchronous = NORMAL
DBIx::Sunny supports nested transaction management based on RAII like DBIx::Class or DBIx::Skinny. It uses DBIx::TransactionManager internally.
DBIx::Sunny sets RaiseError and ShowErrorStatement as true. DBIx::Sunny raises exception and shows current statement if your $dbh occurred exception.
DBIx::Sunny adds file name and line number as SQL comment that invokes SQL statement.
DBIx::Sunny's last_insert_id needs no arguments. It's shortcut for mysql_insertid or last_insert_rowid.
select_(one|row|all) and query methods support auto-expanding arrayref bind parameters.
$dbh->select_all('SELECT * FROM id IN (?)', [1 2 3]) #SQL: 'SELECT * FROM id IN (?,?,?)' #@BIND: (1, 2, 3)
select_(one|row|all) and query methods support named placeholder.
$dbh->select_all('SELECT * FROM users WHERE id IN (:ids) AND status = :status', { ids => [1,2,3], status => 'active', }); #SQL: 'SELECT * FROM users WHERE id IN (?,?,?) AND status = ?' #@BIND: (1, 2, 3, 'active')
DBIx::Sunny allows you to specify data types of bind parameters. If a bind parameter is SQL::Maker::SQLType object, its value is passed as its type, otherwise it is passed as default type (VARCHAR).
use SQL::Maker::SQLType qw/sql_type/; use DBI qw/:sql_types/ $dbh->query( 'INSERT INTO bin_table (bin_col) VALUES (?)', sql_type(\"\xDE\xAD\xBE\xEF", SQL_BINARY)), );
Shortcut for prepare, execute and fetchrow_arrayref->[0]
Shortcut for prepare, execute and fetchrow_hashref
Shortcut for prepare, execute and selectall_arrayref(.., { Slice => {} }, ..)
Shortcut for prepare, execute.
Masahiro Nagano <kazeburo KZBRKZBR@ gmail.com>
DBI, Amon2::DBI
Copyright (C) Masahiro Nagano
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DBIx::Sunny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Sunny
CPAN shell
perl -MCPAN -e shell install DBIx::Sunny
For more information on module installation, please visit the detailed CPAN module installation guide.