GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SQL::Translator::Parser::DBI(3) User Contributed Perl Documentation SQL::Translator::Parser::DBI(3)

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

  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',
    }
  );

This parser accepts an open database handle (or the arguments to create one) and queries the database directly for the information.

The following are acceptable arguments:

  • dbh

    An open DBI database handle. NB: Be sure to create the database with the "FetchHashKeyName => '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'}. 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).

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.

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

DBI, SQL::Translator.
2020-09-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.