package SQL::Translator::Parser::DBI;
# -------------------------------------------------------------------
-# $Id: DBI.pm,v 1.4 2003-10-10 15:52:07 kycl4rk Exp $
+# $Id: DBI.pm 1440 2009-01-17 16:31:57Z jawnsy $
# -------------------------------------------------------------------
-# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
-# darren chamberlain <darren@cpan.org>
+# Copyright (C) 2002-2009 SQLFairy Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
use DBI;
use SQL::Translator;
- my $dbh = DBI->connect(...);
+ my $dbh = DBI->connect('dsn', 'user', 'pass',
+ {
+ RaiseError => 1,
+ FetchHashKeyName => 'NAME_lc',
+ }
+ );
my $translator = SQL::Translator->new(
parser => 'DBI',
use SQL::Translator;
- my $translator = SQL::Translator->new(
- parser => 'DBI',
- dsn => 'dbi:mysql:FOO',
- db_user => 'guest',
- db_password => 'password',
+ my $translator = SQL::Translator->new(
+ parser => 'DBI',
+ parser_args => {
+ dsn => 'dbi:mysql:FOO',
+ db_user => 'guest',
+ db_password => 'password',
+ }
);
=head1 DESCRIPTION
=item * dbh
-An open DBI database handle.
+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.
=item * dsn
use strict;
use DBI;
-use vars qw($VERSION @EXPORT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/;
+use vars qw(@EXPORT);
use constant DRIVERS => {
mysql => 'MySQL',
+ odbc => 'SQLServer',
+ oracle => 'Oracle',
+ pg => 'PostgreSQL',
sqlite => 'SQLite',
sybase => 'Sybase',
pg => 'PostgreSQL',
+ db2 => 'DB2',
};
use Exporter;
use SQL::Translator::Utils qw(debug);
-use SQL::Translator::Parser::DBI::MySQL;
-use SQL::Translator::Parser::DBI::SQLite;
-use SQL::Translator::Parser::DBI::Sybase;
-use SQL::Translator::Parser::DBI::PostgreSQL;
-
use base qw(Exporter);
@EXPORT = qw(parse);
my $pkg = "SQL::Translator::Parser::DBI::$driver";
my $sub = $pkg.'::parse';
- #
- # I can't get this to work. I seem to have to have the "use"
- # statements above.
- #
-# $tr->load( $pkg );
+ $tr->load( $pkg );
eval {
no strict 'refs';