Commit | Line | Data |
6a9f7bae |
1 | package SQL::Translator::Parser::DBI::SQLite; |
2 | |
44659089 |
3 | # ------------------------------------------------------------------- |
4 | # Copyright (C) 2002-2009 SQLFairy Authors |
5 | # |
6 | # This program is free software; you can redistribute it and/or |
7 | # modify it under the terms of the GNU General Public License as |
8 | # published by the Free Software Foundation; version 2. |
9 | # |
10 | # This program is distributed in the hope that it will be useful, but |
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | # General Public License for more details. |
14 | # |
15 | # You should have received a copy of the GNU General Public License |
16 | # along with this program; if not, write to the Free Software |
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
18 | # 02111-1307 USA |
19 | # ------------------------------------------------------------------- |
20 | |
6a9f7bae |
21 | =head1 NAME |
22 | |
23 | SQL::Translator::Parser::DBI::SQLite - parser for DBD::SQLite |
24 | |
25 | =head1 SYNOPSIS |
26 | |
27 | See SQL::Translator::Parser::DBI. |
28 | |
29 | =head1 DESCRIPTION |
30 | |
9156433b |
31 | Queries the "sqlite_master" table for schema definition. The schema |
32 | is held in this table simply as CREATE statements for the database |
33 | objects, so it really just builds up a string of all these and passes |
34 | the result to the regular SQLite parser. Therefore there is no gain |
35 | (at least in performance) to using this module over simply dumping the |
36 | schema to a text file and parsing that. |
6a9f7bae |
37 | |
38 | =cut |
39 | |
40 | use strict; |
41 | use DBI; |
42 | use SQL::Translator::Parser::SQLite; |
43 | use Data::Dumper; |
44 | |
da06ac74 |
45 | use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; |
11ad2df9 |
46 | $VERSION = '1.59'; |
6a9f7bae |
47 | $DEBUG = 0 unless defined $DEBUG; |
48 | |
49 | # ------------------------------------------------------------------- |
50 | sub parse { |
51 | my ( $tr, $dbh ) = @_; |
52 | |
bdfd8a3f |
53 | my $create = join(";\n", |
54 | map { $_ || () } |
55 | @{ $dbh->selectcol_arrayref('select sql from sqlite_master') }, |
6a9f7bae |
56 | ); |
bdfd8a3f |
57 | $create .= ";"; |
58 | $tr->debug( "create =\n$create\n" ); |
6a9f7bae |
59 | |
60 | my $schema = $tr->schema; |
61 | |
6a9f7bae |
62 | SQL::Translator::Parser::SQLite::parse( $tr, $create ); |
63 | return 1; |
64 | } |
65 | |
66 | 1; |
67 | |
68 | # ------------------------------------------------------------------- |
69 | # Where man is not nature is barren. |
70 | # William Blake |
71 | # ------------------------------------------------------------------- |
72 | |
73 | =pod |
74 | |
75 | =head1 AUTHOR |
76 | |
11ad2df9 |
77 | Ken Y. Clark E<lt>kclark@cpan.orgE<gt>. |
6a9f7bae |
78 | |
79 | =head1 SEE ALSO |
80 | |
9156433b |
81 | SQL::Translator::Parser::SQLite. |
6a9f7bae |
82 | |
83 | =cut |