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

AUTHOR

82       Ken Y. Clark <kclark@cpan.org>.
83

SEE ALSO

85       DBI, SQL::Translator.
86
87
88
89perl v5.8.8                       2007-10-24   SQL::Translator::Parser::DBI(3)
Impressum