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             parser_args => {
22                 dbh => $dbh,
23             },
24         );
25
26       Or:
27
28         use SQL::Translator;
29
30         my $translator      =  SQL::Translator->new(
31             parser          => 'DBI',
32             parser_args     => {
33                 dsn         => 'dbi:mysql:FOO',
34                 db_user     => 'guest',
35                 db_password => 'password',
36           }
37         );
38

DESCRIPTION

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

AUTHOR

91       Ken Y. Clark <kclark@cpan.org>.
92

SEE ALSO

94       DBI, SQL::Translator.
95
96
97
98perl v5.32.0                      2020-09-14   SQL::Translator::Parser::DBI(3)
Impressum