Commit | Line | Data |
6a9f7bae |
1 | package SQL::Translator::Parser::DBI::SQLite; |
2 | |
3 | # ------------------------------------------------------------------- |
90075866 |
4 | # $Id: SQLite.pm,v 1.5 2004-02-09 22:23:40 kycl4rk Exp $ |
6a9f7bae |
5 | # ------------------------------------------------------------------- |
90075866 |
6 | # Copyright (C) 2002-4 SQLFairy Authors |
6a9f7bae |
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 | |
9156433b |
33 | Queries the "sqlite_master" table for schema definition. The schema |
34 | is held in this table simply as CREATE statements for the database |
35 | objects, so it really just builds up a string of all these and passes |
36 | the result to the regular SQLite parser. Therefore there is no gain |
37 | (at least in performance) to using this module over simply dumping the |
38 | schema to a text file and parsing that. |
6a9f7bae |
39 | |
40 | =cut |
41 | |
42 | use strict; |
43 | use DBI; |
44 | use SQL::Translator::Parser::SQLite; |
45 | use Data::Dumper; |
46 | |
47 | use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; |
90075866 |
48 | $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; |
6a9f7bae |
49 | $DEBUG = 0 unless defined $DEBUG; |
50 | |
51 | # ------------------------------------------------------------------- |
52 | sub parse { |
53 | my ( $tr, $dbh ) = @_; |
54 | |
bdfd8a3f |
55 | my $create = join(";\n", |
56 | map { $_ || () } |
57 | @{ $dbh->selectcol_arrayref('select sql from sqlite_master') }, |
6a9f7bae |
58 | ); |
bdfd8a3f |
59 | $create .= ";"; |
60 | $tr->debug( "create =\n$create\n" ); |
6a9f7bae |
61 | |
62 | my $schema = $tr->schema; |
63 | |
6a9f7bae |
64 | SQL::Translator::Parser::SQLite::parse( $tr, $create ); |
65 | return 1; |
66 | } |
67 | |
68 | 1; |
69 | |
70 | # ------------------------------------------------------------------- |
71 | # Where man is not nature is barren. |
72 | # William Blake |
73 | # ------------------------------------------------------------------- |
74 | |
75 | =pod |
76 | |
77 | =head1 AUTHOR |
78 | |
da804135 |
79 | Ken Y. Clark E<lt>kclark@cpan.orgE<gt>. |
6a9f7bae |
80 | |
81 | =head1 SEE ALSO |
82 | |
9156433b |
83 | SQL::Translator::Parser::SQLite. |
6a9f7bae |
84 | |
85 | =cut |