Commit | Line | Data |
6a9f7bae |
1 | package SQL::Translator::Parser::DBI::SQLite; |
2 | |
6a9f7bae |
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 | |
9156433b |
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 |
ea93df61 |
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 |
9156433b |
18 | schema to a text file and parsing that. |
6a9f7bae |
19 | |
20 | =cut |
21 | |
22 | use strict; |
23 | use DBI; |
24 | use SQL::Translator::Parser::SQLite; |
25 | use Data::Dumper; |
26 | |
da06ac74 |
27 | use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; |
11ad2df9 |
28 | $VERSION = '1.59'; |
6a9f7bae |
29 | $DEBUG = 0 unless defined $DEBUG; |
30 | |
6a9f7bae |
31 | sub parse { |
32 | my ( $tr, $dbh ) = @_; |
33 | |
bdfd8a3f |
34 | my $create = join(";\n", |
35 | map { $_ || () } |
36 | @{ $dbh->selectcol_arrayref('select sql from sqlite_master') }, |
6a9f7bae |
37 | ); |
bdfd8a3f |
38 | $create .= ";"; |
39 | $tr->debug( "create =\n$create\n" ); |
6a9f7bae |
40 | |
41 | my $schema = $tr->schema; |
42 | |
6a9f7bae |
43 | SQL::Translator::Parser::SQLite::parse( $tr, $create ); |
44 | return 1; |
45 | } |
46 | |
47 | 1; |
48 | |
49 | # ------------------------------------------------------------------- |
50 | # Where man is not nature is barren. |
51 | # William Blake |
52 | # ------------------------------------------------------------------- |
53 | |
54 | =pod |
55 | |
56 | =head1 AUTHOR |
57 | |
11ad2df9 |
58 | Ken Y. Clark E<lt>kclark@cpan.orgE<gt>. |
6a9f7bae |
59 | |
60 | =head1 SEE ALSO |
61 | |
9156433b |
62 | SQL::Translator::Parser::SQLite. |
6a9f7bae |
63 | |
64 | =cut |