|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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] |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
Thank you so much. Everythings worked just fine. You are a life saver.
Take care! ------------------ Thank you |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > PERL and MySQL HELP! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|