File: MyDriver.pm

package info (click to toggle)
libtest-database-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 236 kB
  • sloc: perl: 594; makefile: 2
file content (84 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package Test::Database::Driver::MyDriver;
use strict;
use warnings;

use Test::Database::Driver;
our @ISA = qw( Test::Database::Driver );

# uncomment only if your database engine is file-based
#sub is_filebased {1}

sub _version {
    # return a version string
}

sub dsn {
    my ($self, $dbname) = @_;
    # return a dsn for $dbname
}

# this routine has a default implementation for file-based database engines
sub create_database {
    my ( $self, $dbname, $keep ) = @_;
    $dbname = $self->available_dbname() if !$dbname;

    # create the database if it doesn't exist
    # ...

    # return the handle
    return Test::Database::Handle->new(
        dsn      => $self->dsn($dbname),
        name     => $dbname,
        driver   => $self,
        # ... other fields, like username, password
    );
}

sub drop_database {
    my ( $self, $dbname ) = @_;

    # drop the database
}

# this routine has a default implementation for file-based database engines
sub databases {
    my ($self) = @_;
    # return the names of all databases existing in this driver
}

'MyDriver';

__END__

=head1 NAME

Test::Database::Driver::MyDriver - A Test::Database driver for MyDriver

=head1 SYNOPSIS

    use Test::Database;
    my @handles = Test::Database->handles( 'MyDriver' );

=head1 DESCRIPTION

This module is the C<Test::Database> driver for C<DBD::MyDriver>.

=head1 SEE ALSO

L<Test::Database::Driver>

=head1 AUTHOR

Philippe Bruhat (BooK), C<< <book@cpan.org> >>

=head1 COPYRIGHT

Copyright 2008-2009 Philippe Bruhat (BooK), all rights reserved.

=head1 LICENSE

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

=cut