1SQL::Translator::ParserU:s:eDrBIC(o3n)tributed Perl DocuSmQeLn:t:aTtriaonnslator::Parser::DBI(3)
2
3
4

NAME

6       SQL::Translator::Parser::DBI - "parser" for DBI handles
7

SYNOPSIS

9         use DBI;
10         use SQL::Translator;
11
12         my $dbh = DBI->connect('dsn', 'user', 'pass',
13             {
14                 RaiseError       => 1,
15                 FetchHashKeyName => 'NAME_lc',
16             }
17         );
18
19         my $translator  =  SQL::Translator->new(
20             parser      => 'DBI',
21             dbh         => $dbh,
22         );
23
24       Or:
25
26         use SQL::Translator;
27
28         my $translator      =  SQL::Translator->new(
29             parser          => 'DBI',
30             parser_args     => {
31                 dsn         => 'dbi:mysql:FOO',
32                 db_user     => 'guest',
33                 db_password => 'password',
34           }
35         );
36

DESCRIPTION

38       This parser accepts an open database handle (or the arguments to create
39       one) and queries the database directly for the information.
40
41       The following are acceptable arguments:
42
43       ·   dbh
44
45           An open DBI database handle.  NB:  Be sure to create the database
46           with the "FetchHashKeyName => 'NAME_lc'" option as all the DBI
47           parsers expect lowercased column names.
48
49       ·   dsn
50
51           The DSN to use for connecting to a database.
52
53       ·   db_user
54
55           The user name to use for connecting to a database.
56
57       ·   db_password
58
59           The password to use for connecting to a database.
60
61       There is no need to specify which type of database you are querying as
62       this is determined automatically by inspecting
63       $dbh->{'Driver'}{'Name'}.  If a parser exists for your database, it
64       will be used automatically; if not, the code will fail automatically
65       (and you can write the parser and contribute it to the project!).
66
67       Currently parsers exist for the following databases:
68
69       ·   MySQL
70
71       ·   SQLite
72
73       ·   Sybase
74
75       ·   PostgreSQL (still experimental)
76
77       Most of these parsers are able to query the database directly for the
78       structure rather than parsing a text file.  For large schemas, this is
79       probably orders of magnitude faster than traditional parsing (which
80       uses Parse::RecDescent, an amazing module but really quite slow).
81
82       Though no Oracle parser currently exists, it would be fairly easy to
83       query an Oracle database directly by using DDL::Oracle to generate a
84       DDL for the schema and then using the normal Oracle parser on this.
85       Perhaps future versions of SQL::Translator will include the ability to
86       query Oracle directly and skip the parsing of a text file, too.
87

AUTHOR

89       Ken Y. Clark <kclark@cpan.org>.
90

SEE ALSO

92       DBI, SQL::Translator.
93
94
95
96perl v5.12.0                      2009-08-18   SQL::Translator::Parser::DBI(3)
Impressum