Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Creating o non-existing database

Reply
Thread Tools

Creating o non-existing database

 
 
Nikos
Guest
Posts: n/a
 
      04-12-2005
This is soem 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?
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-13-2005
Nikos <(E-Mail Removed)> wrote:

> This is soem per of my make.pl



Huh?

Is that supposed to be an English sentence?


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
peter pilsl
Guest
Posts: n/a
 
      04-13-2005
Nikos wrote:
>
> 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.
>


Evidentely this is not a perl-problem. I dont know what it takes on your
sql-server to create a database. With postgreSQL there are mainly two
options:
i) call an extra programm coming with pgSQL
ii) connect to another database and create the needed database. Best the
postgres-system-datebase is used, cause it exists on most installations.

peter




--
http://www.goldfisch.at/know_list
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      04-13-2005
Nikos wrote:
> What can i do so that Perl create the database nikos_db if it never benn
> created?


You could check how it's done in Webmin.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Spock
Guest
Posts: n/a
 
      04-15-2005
Whats Webmin?
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      04-15-2005
Spock wrote:
> Whats Webmin?


http://www.google.com/

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      04-15-2005
Nikos <(E-Mail Removed)> wrote:
> This is soem 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', 'root', '')

> : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', '*****')


: DBI->connect('DBI:mysql::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.


If you read the error it gives, then it should have been obvious what the
problem was. You can't connect to the server and specify a non-existant
database as your default. Connect the server without specifying any default
database, (re)create the database you want, then switch into it.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net Web Controls 0 06-01-2005 02:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM
Creating database in ASP .NET Robin ASP .Net 2 10-16-2003 05:21 PM



Advertisments