in reply to how to create a database in perl

I didn't realize it was this easy... Just don't give a DB name.

use DBI; my $dbh = DBI->connect("dbi:mysql:", "user","pass"); print 1 == $dbh->do("create database MooCow") ? "YAY\n":"BOO\n";

I'm guessing that's driver specific behavior.

Replies are listed 'Best First'.
Re^2: how to create a database in perl
by Anonymous Monk on Jan 28, 2011 at 15:20 UTC
    ok, thanks, but if you don't give a name, how can i get the database handle to perform queries on my database once i have created it. thanks

      You can just run "use mynewdbname" as a sql statement in do:

      $dbh->do( "use mynewdbname" )

      I don't use mysql, but I find plenty of usage of that when searching in google code with $dbh->do("use

      Simply disconnect(), and connect again with the name of the newly created database.