Commit | Line | Data |
6a9f7bae |
1 | package SQL::Translator::Parser::DBI::SQLite; |
2 | |
3 | # ------------------------------------------------------------------- |
da804135 |
4 | # $Id: SQLite.pm,v 1.3 2003-10-03 19:47:19 kycl4rk Exp $ |
6a9f7bae |
5 | # ------------------------------------------------------------------- |
6 | # Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>. |
7 | # |
8 | # This program is free software; you can redistribute it and/or |
9 | # modify it under the terms of the GNU General Public License as |
10 | # published by the Free Software Foundation; version 2. |
11 | # |
12 | # This program is distributed in the hope that it will be useful, but |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | # General Public License for more details. |
16 | # |
17 | # You should have received a copy of the GNU General Public License |
18 | # along with this program; if not, write to the Free Software |
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
20 | # 02111-1307 USA |
21 | # ------------------------------------------------------------------- |
22 | |
23 | =head1 NAME |
24 | |
25 | SQL::Translator::Parser::DBI::SQLite - parser for DBD::SQLite |
26 | |
27 | =head1 SYNOPSIS |
28 | |
29 | See SQL::Translator::Parser::DBI. |
30 | |
31 | =head1 DESCRIPTION |
32 | |
33 | Queries the "sqlite_master" table for schema definition. |
34 | |
35 | =cut |
36 | |
37 | use strict; |
38 | use DBI; |
39 | use SQL::Translator::Parser::SQLite; |
40 | use Data::Dumper; |
41 | |
42 | use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; |
da804135 |
43 | $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/; |
6a9f7bae |
44 | $DEBUG = 0 unless defined $DEBUG; |
45 | |
46 | # ------------------------------------------------------------------- |
47 | sub parse { |
48 | my ( $tr, $dbh ) = @_; |
49 | |
bdfd8a3f |
50 | my $create = join(";\n", |
51 | map { $_ || () } |
52 | @{ $dbh->selectcol_arrayref('select sql from sqlite_master') }, |
6a9f7bae |
53 | ); |
bdfd8a3f |
54 | $create .= ";"; |
55 | $tr->debug( "create =\n$create\n" ); |
6a9f7bae |
56 | |
57 | my $schema = $tr->schema; |
58 | |
6a9f7bae |
59 | SQL::Translator::Parser::SQLite::parse( $tr, $create ); |
60 | return 1; |
61 | } |
62 | |
63 | 1; |
64 | |
65 | # ------------------------------------------------------------------- |
66 | # Where man is not nature is barren. |
67 | # William Blake |
68 | # ------------------------------------------------------------------- |
69 | |
70 | =pod |
71 | |
72 | =head1 AUTHOR |
73 | |
da804135 |
74 | Ken Y. Clark E<lt>kclark@cpan.orgE<gt>. |
6a9f7bae |
75 | |
76 | =head1 SEE ALSO |
77 | |
78 | perl(1), Parse::RecDescent, SQL::Translator::Schema. |
79 | |
80 | =cut |