SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 2nd, 2000, 10:32 PM
nevolin_t nevolin_t is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Chelyabinsk, Russia
Posts: 3 nevolin_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi all!

Could anyone show me how may I connect from perl to mysql. Simple a piece of code will be enough. Thank you.

------------------
___
Tim

Reply With Quote
  #2  
Old September 2nd, 2000, 11:52 PM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
hehe, there's a little more to it than that

do you have DBI and DBD:mysql installed?

if so, check out the DBI documentation that came with your source to find examples of using the module

your code will look something like this
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>use DBI;

$dbh = DBI->connect('DBI:mysql:dbName')
or die "Couldn't connect to database: " . DBI->errstr;
$sth = $dbh->prepare('SELECT * FROM tableName')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;
while (@data = $sth->fetchrow_array())
{
$field1 = $data[0];
$field2 = $data[1];
}
$sth->finish;
$dbh->disconnect;[/code]

[This message has been edited by RyanP (edited September 02, 2000).]

Reply With Quote
  #3  
Old September 3rd, 2000, 09:29 PM
nevolin_t nevolin_t is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Chelyabinsk, Russia
Posts: 3 nevolin_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank's for explanations.
I found DBI module at www.perl.com/CPAN-local/modules/by-module/ but not found DBD:mysql. Where I can find it? Do you know?

------------------
___
Tim

Reply With Quote
  #4  
Old September 3rd, 2000, 10:40 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
Don't worry about DBD:mysql. DBI is all you need.

Reply With Quote
  #5  
Old September 4th, 2000, 01:08 AM
nevolin_t nevolin_t is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Chelyabinsk, Russia
Posts: 3 nevolin_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
One more problem URL.

I'm on WinNT. I unpacked the DBI archive, if I simple copy DBI.pm into perl/lib directory apache rase the error on "use DBI" line in CGI script.

Can't find loadable module for DBI.pm line...

Shall I first build anything how indexed in readme file? Other instruction I found say that it doesn't nessesary on WinNT.
Thouth I tryed to build it. Command: "perl Makefile.PL" passed and create "makefile." file, but commnad: "make" rase an error.

Did you install this module on WinNT or do you know anyone who did it? May be there is a ready to use DBI.pm module for WinNT?

I'm in misunderstandings.

------------------
___
Tim

Reply With Quote
  #6  
Old September 4th, 2000, 11:37 AM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
are you using ActivePerl? if so, then you should probably use their /bin/ppm to automatically download and install DBI

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > connect to mysql


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 | 
  
 





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