1 package DBIx::DataSource;
4 use vars qw($VERSION @ISA @EXPORT_OK $errstr);
8 @EXPORT_OK = qw( create_database drop_database );
14 DBIx::DataSource - Database-independant create and drop functions
18 use DBIx::DataSource qw( create_database drop_database );
20 create_database( $data_source, $username, $password )
21 or warn $DBIx::DataSource::errstr;
23 drop_database( $data_source, $username, $password )
24 or warn $DBIx::DataSource::errstr;
28 This module implements create_database and drop_database functions for
29 databases. It aims to provide a common interface to database creation and
30 deletion regardless of the actual database being used.
32 Currently supported databases are MySQL and PostgreSQL. Assistance adding
33 support for other databases is welcomed and relatively simple - see
34 L<DBIx::DataSource::Driver>.
40 =item create_database DATA_SOURCE USERNAME PASSWORD
42 Create the database specified by the given DBI data source.
47 my( $dsn, $user, $pass ) = @_;
48 my $driver = _load_driver($dsn);
49 eval "DBIx::DataSource::$driver->create_database( \$dsn, \$user, \$pass )"
50 or do { $errstr=$@ if $@; ''; };
53 =item drop_database DATA_SOURCE
55 Drop the database specified by the given DBI data source.
60 my( $dsn, $user, $pass ) = @_;
61 my $driver = _load_driver($dsn);
62 eval "DBIx::DataSource::$driver->drop_database( \$dsn, \$user, \$pass )"
63 or do { $errstr=$@ if $@; ''; };
68 $datasrc =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i #nicked from DBI->connect
69 or '' =~ /()/; # ensure $1 etc are empty if match fails
70 my $driver = $1 or die "can't parse data source: $datasrc";
71 require "DBIx/DataSource/$driver.pm";
79 Ivan Kohler <ivan-dbix-datasource@420.am>
83 Copyright (c) 2000 Ivan Kohler
84 Copyright (c) 2000 Mail Abuse Prevention System LLC
86 This program is free software; you can redistribute it and/or modify it under
87 the same terms as Perl itself.
91 If DBI data sources were objects, these functions would be methods.
95 L<DBIx::DataSource::Driver>, L<DBIx::DataSource::mysql>, L<DBIx::DataSource::Pg>,