#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Kuwait
    Posts
    47
    Rep Power
    15
    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. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    15
    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]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Kuwait
    Posts
    47
    Rep Power
    15
    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!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Kuwait
    Posts
    47
    Rep Power
    15
    Thank you so much. Everythings worked just fine. You are a life saver.

    Take care!

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

Similar Threads

  1. MySQL "UPDATE" query in Perl
    By Volitics in forum Perl Programming
    Replies: 15
    Last Post: March 18th, 2004, 01:31 PM
  2. Perl, MySQL password verification
    By planetjanet in forum Perl Programming
    Replies: 2
    Last Post: January 17th, 2004, 05:06 PM
  3. MySQL - Perl WHERE
    By ryche88OM in forum MySQL Help
    Replies: 0
    Last Post: January 13th, 2004, 01:59 PM
  4. MySQL Perl Question
    By ryche88OM in forum MySQL Help
    Replies: 0
    Last Post: January 6th, 2004, 10:32 PM
  5. SLOW Perl / MySQL execution times
    By Chireru in forum MySQL Help
    Replies: 9
    Last Post: January 2nd, 2004, 02:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo