MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 11th, 2000, 07:11 AM
mohamed mohamed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Kuwait
Posts: 47 mohamed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I am hosting with a particular copmpany, and I have asked them to setup a database for me. They did. I wrote a small program in perl that uses DBI to check for available drivers. When I run it, it does not see the MySQL driver. I contacted the host, but I never got a clear answer. It seems that I might be at fault here. Maybe I am missing something.
What do I need to do given that I have my database name, user name and password?



------------------
Thank you

Reply With Quote
  #2  
Old August 11th, 2000, 08:33 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
First off, check that the database driver is installed: Log into your shell and type:
perl -MDBD::mysql
If you get an error along the lines of "Can't locate DBD::mysql in @INC...." then the database driver is not installed -- ask your sysadmin to install it for you.

If it is installed, then you should be able to connect to your database with:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
use DBI;

# connect
my $dbh = DBI->connect('dbi:mysql:dbname', 'user', 'pass');

# make DBI raise any errors by calling die
$dbh->{RaiseError} = 1;

# prepare a SQL statement
my $sth = $dbh->prepare('select * from emp');

# execute it
$sth->execute;

# print out the results
while( my @results = $sth->fetchrow_array ) {
foreach (@results) {
print $_, "t";
}
}

# close the statement handle
$sth->finish;

# disconnect from the database
$dbh->disconnect;
[/code]

Reply With Quote
  #3  
Old August 11th, 2000, 09:26 AM
mohamed mohamed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Kuwait
Posts: 47 mohamed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I am so grateful to you. I tried the perl -MDBD::mysql command, and it did not return anything. I tried it with some other nonexistant database and it returned the error you mentioned. I guess mysql is there. I will try connect() as soon as possible and let you know of the results.

Thank you so very very much!

Reply With Quote
  #4  
Old August 11th, 2000, 12:50 PM
mohamed mohamed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Kuwait
Posts: 47 mohamed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Thank you so much. Everythings worked just fine. You are a life saver.

Take care!

------------------
Thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > PERL and MySQL HELP!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway