On 10/18/02 at 1:56 PM, [EMAIL PROTECTED] (Hastie, Christa) wrote: > Have you tried just doing something like: > $dbh->do("CREATE TABLE tablename") or die "ERROR:" . $dbh->errstr; > > I think that would work :) > Let me know... > Yes Christa, something like that will work fine. But I'm looking to create a new database not a table. :-(
The problem I can't figure out is, normally to connect with DBI you might say: my $dbh = DBI->connect($db, $db_user, $db_pass, ) or die "connecting: $dbh::errstr"; where $db is your database name. So how do you connect and talk to MySQL without an existing database with DBI? A > -----Original Message----- > From: Andrew Brosnan [mailto:andrew@;broscom.com] > Sent: Friday, October 18, 2002 1:54 PM > To: Hardy Merrill > Cc: Post; [EMAIL PROTECTED] > Subject: Re: Create database > > > 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. I'm not talking about installing a > db program here; just exectuing some SQL like I might from the shell: CREATE > DATABASE DatabaseName; > > > > Have you installed the DBI module and the DBD module for your > > database? > Of course. I have no problem using DBI with the existing MySQL db's; I just > wanted to write some code that would allow me to create a new db via DBI. > > > > Since you referred to "datasource", I'm guessing you're on a Windows > > platform - is that > > right? > Heavans No! FreeBSD, Mac OS X, Linux...anything but!!! ;-) The DBI docs and > Descartes book often refer to a particular driver & database as a > datasource. > > > > Some more info would be helpful. > Not sure what else is needed. I assume you misunderstood my question. Just > the way you might create a table or make a query by executing some SQL via > DBI, I want to be able to create a new database from my perl script via DBI. > > Thanks Hardy! > > Andrew > > > -- > > Hardy Merrill > > Senior Software Engineer > > Red Hat, Inc. > > > > > > Andrew Brosnan [[EMAIL PROTECTED]] wrote: > > > Hello List, > > > > > > I'm looking to *create* a database with DBI. I couldn't glean this > > > from the docs. Seems like you first need to connect to a > > > datasource(database) to issue statements. > > > > > > Is there a way to 'CREATE DATABASE DatabaseName;' with DBI? > > > > > > Thanks, > > > Andrew > > >