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; |
f27f9229 |
23 | use warnings; |
6a9f7bae |
24 | use DBI; |
25 | use SQL::Translator::Parser::SQLite; |
26 | use Data::Dumper; |
27 | |
0c04c5a2 |
28 | our ( $DEBUG, @EXPORT_OK ); |
29 | our $VERSION = '1.59'; |
6a9f7bae |
30 | $DEBUG = 0 unless defined $DEBUG; |
31 | |
6a9f7bae |
32 | sub parse { |
33 | my ( $tr, $dbh ) = @_; |
34 | |
bdfd8a3f |
35 | my $create = join(";\n", |
36 | map { $_ || () } |
37 | @{ $dbh->selectcol_arrayref('select sql from sqlite_master') }, |
6a9f7bae |
38 | ); |
bdfd8a3f |
39 | $create .= ";"; |
40 | $tr->debug( "create =\n$create\n" ); |
6a9f7bae |
41 | |
42 | my $schema = $tr->schema; |
43 | |
6a9f7bae |
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 | |
11ad2df9 |
59 | Ken Y. Clark E<lt>kclark@cpan.orgE<gt>. |
6a9f7bae |
60 | |
61 | =head1 SEE ALSO |
62 | |
9156433b |
63 | SQL::Translator::Parser::SQLite. |
6a9f7bae |
64 | |
65 | =cut |