On 10/18/02 at 2:10 PM, [EMAIL PROTECTED] (Jeff Zucker) wrote:
> Andrew Brosnan wrote:
>
> > On 10/18/02 at 4:26 PM, [EMAIL PROTECTED] (Hardy Merrill) wrote:
> >
> >>What database are you using?
> >>
> > Not sure why it would matter, but MySQL.
>
>
> Yes it matters. This works for me using MySQL:
>
> my $existing_db = $your_old_db_here;
> my $new_db = $your_new_db_here;
> my $dbh = DBI->connect("dbi:mysql:database=$existing_db" ...);
> $dbh->do("CREATE DATABASE $new_db");
> $dbh->do("USE $newdb");
> # commands to create and query tables in $new_db
>
> --
> Jeff
>
>
Yes Jeff, I thought the same thing. But that won't work for me in this
case. I need to be able to create a new db without assuming that there
is an existing one (or at least I might not know what it is).
What I really need is a way to execute from dbi, what I might normally
do via the shell:
CREATE DATABASE DatabaseName;
> Yes it matters.
I assume of course that I would change db drivers in my script as
needed, but I'd otherwise like the code to be dbi(data base independant)
Thanks!!
Any other thoughts?
Andrew