use DBIx::DBSchema;
$schema = new DBIx::DBSchema @dbix_dbschema_table_objects;
- $schema = new_from_dsn DBIx::DBSchema $dsn, $user, $pass;
$schema = new_odbc DBIx::DBSchema $dbh;
+ $schema = new_odbc DBIx::DBSchema $dsn, $user, $pass;
$schema = new_native DBIx::DBSchema $dbh;
+ $schema = new_native DBIx::DBSchema $dsn, $user, $pass;
$schema->save("filename");
$schema = load DBIx::DBSchema "filename";
}
-=item new_odbc_from_dsn DATA_SOURCE USERNAME PASSWORD
+=item new_odbc DATABASE_HANDLE || DATA_SOURCE USERNAME PASSWORD [ ATTR ]
-Connects to the specified DBI data source and creates a DBIx::DBSchema object
-from it using new_odbc.
-
-=cut
-
-sub new_odbc_from_dsn {
- my($proto, $dsn, $user, $pass ) = @_;
- my $dbh = DBI->connect( $dsn, $user, $pass ) or die $DBI::errstr;
- my $self = $proto->new_odbc($dbh);
- $dbh->disconnect; #silly DBI
- $self;
-}
-
-=item new_odbc DATABASE_HANDLE
-
-Creates a new DBIx::DBSchema object from the supplied DBI database handle.
-This uses the experimental DBI type_info method to create a schema with
-standard (ODBC) SQL column types that most closely correspond to any
-non-portable column types. Use this to import a schema that you wish to use
-with many different database engines. Although primary key and (unique) index
-information will only be read from databases with DBIx::DBSchema::DBD drivers
-(currently MySQL and PostgreSQL), import of column names and attributes
-*should* work for any database.
+Creates a new DBIx::DBSchema object from an existing data source, which can be
+specified by passing an open DBI database handle, or by passing the DBI data
+source name, username, and password. This uses the experimental DBI type_info
+method to create a schema with standard (ODBC) SQL column types that most
+closely correspond to any non-portable column types. Use this to import a
+schema that you wish to use with many different database engines. Although
+primary key and (unique) index information will only be read from databases
+with DBIx::DBSchema::DBD drivers (currently MySQL and PostgreSQL), import of
+column names and attributes *should* work for any database.
=cut
sub new_odbc {
- my($proto, $dbh) = @_;
+ my($proto, $dbh) = (shift, shift);
+ $dbh = DBI->connect( $dbh, @_ ) or die $DBI::errstr unless ref($dbh);
$proto->new(
map { new_odbc DBIx::DBSchema::Table $dbh, $_ } _tables_from_dbh($dbh)
);
}
-=item new_native_from_dsn DATA_SOURCE USERNAME PASSWORD
-
-Connects to the specified DBI data source and creates a DBIx::DBSchema object
-from it using new_native.
-
-=cut
-
-sub new_native_from_dsn {
- my($proto, $dsn, $user, $pass) = @_;
- my $dbh = DBI->connect( $dsn, $user, $pass ) or die $DBI::errstr;
- my $self = $proto->new_native($dbh);
- $dbh->disconnect; #silly DBI
- $self;
-}
-
-=item new_native DATABASE_HANDLE
+=item new_native DATABASE_HANDLE || DATA_SOURCE USERNAME PASSWORD [ ATTR ]
-Creates a new DBIx::DBSchema object from the supplied DBI database handle. This
-uses database-native methods to read the schema, and will preserve any
-non-portable column types. The method is only available if there is a
-DBIx::DBSchema::DBD for the corresponding database engine (currently, MySQL and
-PostgreSQL).
+Creates a new DBIx::DBSchema object from an existing data source, which can be
+specified by passing an open DBI database handle, or by passing the DBI data
+source name, username and password. This uses database-native methods to read
+the schema, and will preserve any non-portable column types. The method is
+only available if there is a DBIx::DBSchema::DBD for the corresponding database engine (currently, MySQL and PostgreSQL).
=cut
sub new_native {
- my($proto, $dbh) = @_;
+ my($proto, $dbh) = (shift, shift);
+ $dbh = DBI->connect( $dbh, @_ ) or die $DBI::errstr unless ref($dbh);
$proto->new(
map { new_native DBIx::DBSchema::Table ( $dbh, $_ ) } _tables_from_dbh($dbh)
);