our > use vars
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / DBI / SQLite.pm
1 package SQL::Translator::Parser::DBI::SQLite;
2
3 =head1 NAME
4
5 SQL::Translator::Parser::DBI::SQLite - parser for DBD::SQLite
6
7 =head1 SYNOPSIS
8
9 See SQL::Translator::Parser::DBI.
10
11 =head1 DESCRIPTION
12
13 Queries the "sqlite_master" table for schema definition.  The schema
14 is held in this table simply as CREATE statements for the database
15 objects, so it really just builds up a string of all these and passes
16 the result to the regular SQLite parser.  Therefore there is no gain
17 (at least in performance) to using this module over simply dumping the
18 schema to a text file and parsing that.
19
20 =cut
21
22 use strict;
23 use warnings;
24 use DBI;
25 use SQL::Translator::Parser::SQLite;
26 use Data::Dumper;
27
28 our ( $DEBUG, @EXPORT_OK );
29 our $VERSION = '1.59';
30 $DEBUG   = 0 unless defined $DEBUG;
31
32 sub parse {
33     my ( $tr, $dbh ) = @_;
34
35     my $create = join(";\n",
36         map { $_ || () }
37         @{ $dbh->selectcol_arrayref('select sql from sqlite_master') },
38     );
39     $create .= ";";
40     $tr->debug( "create =\n$create\n" );
41
42     my $schema = $tr->schema;
43
44     SQL::Translator::Parser::SQLite::parse( $tr, $create );
45     return 1;
46 }
47
48 1;
49
50 # -------------------------------------------------------------------
51 # Where man is not nature is barren.
52 # William Blake
53 # -------------------------------------------------------------------
54
55 =pod
56
57 =head1 AUTHOR
58
59 Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
60
61 =head1 SEE ALSO
62
63 SQL::Translator::Parser::SQLite.
64
65 =cut