Nik has asked for the wisdom of the Perl Monks concerning the following question:

This is some per of my make.pl Its supposed to create first time the database nikos_db or if its already there to just delete it and recreate it. $db = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net') ? DBI->connect('DBI:mysql:nikos_db', 'root', '') : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', '**** +*') or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit +0; $db->do( "drop database if exists nikos_db" ); $db->do( "create database nikos_db" ); $db->do( "use nikos_db" );
If the database alrady exists no problem but if it want to be creates at the time then the first db gives an error when i run make.pl and i must then manually create it through mysql statemets in console.

What can i do so that Perl create the database nikos_db if it never benn created?

Replies are listed 'Best First'.
Re: Creating a non-existing database through Perl
by gam3 (Curate) on Apr 15, 2005 at 18:13 UTC
    Use a database that you always exists in your connect such as 'DBI:mysql:mysql'
    -- gam3
    A picture is worth a thousand words, but takes 200K.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Creating a non-existing database through Perl
by dragonchild (Archbishop) on Apr 15, 2005 at 18:10 UTC
    How would you create the database from the commandline mysql tool? You'd connect to the main database (I forget the name), create it there, then reconnect to the database. The way to do this would involve create a second DB connection if you need it.
    A reply falls below the community's threshold of quality. You may see it by logging in.