SQL::Tr...er::DBI(3)
πΈ NAME πΈ
okay bestie, welcome to SQL::Tr...er::DBI(3) π
β it's a User Contributed Perl Documentation page for SQL::Translator::Parser::DBI, aka the βparserβ for DBI handles. no cap, that's the whole assignment. π«Ά
β¨ SYNOPSIS β¨
so first flavor: you already have an open $dbh and you're ready to go:
use DBI;
use SQL::Translator;
my $dbh = DBI->connect('dsn', 'user', 'pass',
{
RaiseError => 1,
FetchHashKeyName => 'NAME_lc',
}
);
my $translator = SQL::Translator->new(
parser => 'DBI',
parser_args => {
dbh => $dbh,
},
);
Or:
use SQL::Translator;
my $translator = SQL::Translator->new(
parser => 'DBI',
parser_args => {
dsn => 'dbi:mysql:FOO',
db_user => 'guest',
db_password => 'password',
}
);
π DESCRIPTION π
okay so this parser accepts an open database handle (or the arguments to create one) and queries the database directly for the information. direct-query energy, literally. π₯
The following are acceptable arguments:
dbhβ an openDBIdatabase handle. NB: Be sure to create the database with theFetchHashKeyName => 'NAME_lc'option as all the DBI parsers expect lowercased column names.dsnβ the DSN to use for connecting to a database.db_userβ the user name to use for connecting to a database.db_passwordβ the password to use for connecting to a database.
There is no need to specify which type of database you are querying as this is determined automatically by inspecting $dbh->{'Driver'}{'Name'}. the code just knows, iykyk. If a parser exists for your database, it will be used automatically; if not, the code will fail automatically (and you can write the parser and contribute it to the project!). π«‘
Currently parsers exist for the following databases:
- MySQL π¬
- SQLite πͺΆ
- Sybase π§
- PostgreSQL (still experimental) π§ͺ
Most of these parsers are able to query the database directly for the structure rather than parsing a text file. For large schemas, this is probably orders of magnitude faster than traditional parsing (which uses Parse::RecDescent, an amazing module but really quite slow). big schema? this is your moment β
Though no Oracle parser currently exists, it would be fairly easy to query an Oracle database directly by using DDL::Oracle to generate a DDL for the schema and then using the normal Oracle parser on this. Perhaps future versions of SQL::Translator will include the ability to query Oracle directly and skip the parsing of a text file, too. future goals, manifesting it π¦
π«Ά AUTHOR π«Ά
Ken Y. Clark <kclark@cpan.org>. iconic. π
π SEE ALSO π
DBI, SQL::Translator. go read those bestie, fr fr. π
made with π by perl v5.42.0 on 2024-12-12 β SQL::Tr...er::DBI(3) out! π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Translator 1.660.0-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms