File: make_dbictest_db.pm

package info (click to toggle)
libdbix-class-schema-loader-perl 0.03009-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 252 kB
  • ctags: 102
  • sloc: perl: 1,636; makefile: 44
file content (37 lines) | stat: -rw-r--r-- 906 bytes parent folder | download | duplicates (3)
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
package make_dbictest_db;

use strict;
use warnings;
use DBI;

eval { require DBD::SQLite };
my $class = $@ ? 'SQLite2' : 'SQLite';

my $fn = './t/dbictest.db';

unlink($fn);
our $dsn = "dbi:$class:dbname=$fn";
my $dbh = DBI->connect($dsn);

$dbh->do($_) for (
    q|CREATE TABLE foo (
        fooid INTEGER PRIMARY KEY,
        footext TEXT
      )|,
    q|CREATE TABLE bar (
        barid INTEGER PRIMARY KEY,
        fooref INTEGER REFERENCES foo(fooid)
      )|,
    q|INSERT INTO foo VALUES (1,'Foo text for number 1')|,
    q|INSERT INTO foo VALUES (2,'Foo record associated with the Bar with barid 3')|,
    q|INSERT INTO foo VALUES (3,'Foo text for number 3')|,
    q|INSERT INTO foo VALUES (4,'Foo text for number 4')|,
    q|INSERT INTO bar VALUES (1,4)|,
    q|INSERT INTO bar VALUES (2,3)|,
    q|INSERT INTO bar VALUES (3,2)|,
    q|INSERT INTO bar VALUES (4,1)|,
);

END { unlink($fn); }

1;