DB-Object

 view release on metacpan or  search on metacpan

lib/DB/Object/SQLite.pm  view on Meta::CPAN

        # Not used
        # LongReadLen                   => 1,
        # LongTruncOk                   => 1,
        # CompatMode                    => 1,
        # If you set this to true, "do" method will process multiple statements at one go.
        # This may be handy, but with performance penalty. See above for details.
        sqlite_allow_multiple_statements => 1,
        # If you set this to true, DBD::SQLite tries to see if the bind values are number or
        # not, and does not quote if they are numbers.
        sqlite_see_if_its_a_number       => 1,
        sqlite_unicode                   => 1,
        # Returns an unprepared part of the statement you pass to "prepare".  Typically this
        # contains nothing but white spaces after a semicolon. 
        sqlite_unprepared_statements     => 0,
        # If you set this to true, DBD::SQLite tries to issue a "begin immediate transaction"
        # (instead of "begin transaction") when necessary.
        sqlite_use_immediate_transaction => 1,
        sqlite_version                   => 0,
    );
    # Only those attribute exist
    # Using an a non existing attribute produce an exception, so we better avoid

lib/DB/Object/SQLite.pm  view on Meta::CPAN

    return( \@options );
}

# Inherited by DB::Object, however, DB::Object::connect() will call our subroutine 
# _dbi_connect which format in a particular way the dsn.
sub connect
{
    my $that  = shift( @_ );
    my $param = $that->_connection_params2hash( @_ ) || return;
    $param->{driver} = 'SQLite';
    $param->{sqlite_unicode} = 1;
    return( $that->SUPER::connect( $param ) );
}

# NOTE: sub constant_to_datatype is inherited

# sub copy

# sub create_table($;%)

# See DB::Object

lib/DB/Object/SQLite.pm  view on Meta::CPAN

    $param->{host} = 'localhost' if( !length( $param->{host} ) );
    $param->{port} = 0 if( !length( $param->{port} ) );
    return( $param );
}

sub _check_default_option
{
    my $self = shift( @_ );
    my $opts = $self->_get_args_as_hash( @_ );
    return( $self->error( "Provided option is not a hash reference." ) ) if( !$self->_is_hash( $opts => 'strict' ) );
    $opts->{sqlite_unicode} = 1 if( !CORE::exists( $opts->{sqlite_unicode} ) );
    return( $opts );
}

sub _connection_options
{
    my $self  = shift( @_ );
    my $param = shift( @_ );
    my @sqlite_params = grep( /^sqlite_/, keys( %$param ) );
    my $opt = $self->SUPER::_connection_options( $param );
    @$opt{ @sqlite_params } = @$param{ @sqlite_params };

lib/DB/Object/SQLite.pm  view on Meta::CPAN


sub _connection_parameters
{
    my $self  = shift( @_ );
    my $param = shift( @_ );
    # Even though login, password, server, host are not used, I was hesitating, but decided to leave them as ok, and ignore them
    # Or maybe should I issue an error when they are provided?
    my $core = [qw( db login passwd host port driver database server opt uri debug cache_connections cache_table unknown_field )];
    my @sqlite_params = grep( /^sqlite_/, keys( %$param ) );
    # See DBD::SQLite for the list of valid parameters
    # E.g.: sqlite_open_flags sqlite_busy_timeout sqlite_use_immediate_transaction sqlite_see_if_its_a_number sqlite_allow_multiple_statements sqlite_unprepared_statements sqlite_unicode sqlite_allow_multiple_statements sqlite_use_immediate_transacti...
    push( @$core, @sqlite_params );
    return( $core );
}

sub _dbi_connect
{
    my $self = shift( @_ );
    my $dbh  = $self->{dbh} = $self->SUPER::_dbi_connect( @_ );
    # my $func = $self->{_func};
    my $func = $self->{_func};

lib/DB/Object/SQLite.pm  view on Meta::CPAN

Can be changed.

=item * C<sqlite_allow_multiple_statements>

Can be changed.

=item * C<sqlite_see_if_its_a_number>

Can be changed.

=item * C<sqlite_unicode>

Can be changed.

=item * C<sqlite_unprepared_statements>

Is read-only.

=item * C<sqlite_use_immediate_transaction>

Can be changed.

lib/DB/Object/SQLite.pm  view on Meta::CPAN

Any arguments provided are passed along to L<DBD::SQLite/commit>

=head2 compile_options

Returns the cached list of SQLite compiled options. The cached file is in the file C<sql_sqlite_compile_options.cfg> in the sytem directory.

=head2 connect

Same as L<DB::Object/connect>, only specific to SQLite.

It sets C<sqlite_unicode> to a true value in the connection parameters returned by L</_connection_params2hash>

See L</_connection_params2hash>

=head2 copy

This is an inherited method from L<DB::Object/copy>

=head2 create_table

This is an inherited method from L<DB::Object/create_table>

lib/DB/Object/SQLite.pm  view on Meta::CPAN

The database is name, if not set, is derived from the base path of the I<database_file>

The I<host> property is set to C<localhost> and I<port> property to C<0>

It returns the hash reference of parameters thus processed.

=head2 _check_default_option

Provided with an hash or hash reference of options and this will check it and set some default value.

The only default property this sets is C<sqlite_unicode> to true.

It returns the hash reference of options.

=head2 _connection_options

Provided with an hash reference of parameters and this will check them and returns an hash reference of options who name start with C<sqlite_>

=head2 _connection_parameters

Provided with an hash or hash reference of connection parameters and this will extra all the properties that start with C<sqlite_/> and add them to an array of core properties: db login passwd host port driver database server opt uri debug



( run in 0.224 second using v1.01-cache-2.11-cpan-f29a10751f0 )