The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Database::Temp - Create an ad-hoc database which drops itself automatically

VERSION

version 0.003

SYNOPSIS

    use DBI;
    my $db = Database::Temp->new(
        driver => 'SQLite',
    );
    my $dbh = DBI->connect( $db->connection_info );
    my $rows = $dbh->selectall_arrayref(
        "SELECT 1, 1+2",
    );

DESCRIPTION

With Database::Temp you can quickly create a temporary database and be sure it gets removed automatically when your reference to it is deleted, normally when the scope ends.

new

Create a temporary database.

Parameters

driver

Available drivers: SQLite. No default value.

basename
name

The full name of a database consists of two parts: basename and name. By default the basename is "database_temp_" and name is a random string of eight letters and numbers. You can change both of these if you need to.

cleanup

Remove database after use. Default: 1.

init
deinit

Pointer to an initializing subroutine or just a SQL script.

args

Special arguments for the creation of the database. These are mentioned separately in the equivalent driver documentation.

is_available

Confirm a driver is available and it can create a temporary database.

Return boolean

Parameters

driver

Available drivers: SQLite. No default value.

random_name

Generate a random name. A string of 8 random letters and characters.

STATUS

This module is currently being developed so changes in the API are possible.

AUTHOR

Mikko Koivunalho <mikkoi@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Mikko Johannes Koivunalho.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.