Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old May 8th, 2000, 02:22 AM
Amit Amit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 6 Amit User rank is Private First Class (20 - 50 Reputation Level)Amit User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Amit
How can i connect PERL with MySQL

Reply With Quote
  #2  
Old May 8th, 2000, 06:53 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
Amit,

you should use dbi-dbd interface for connecting the perl with mysql.

here is an example:

#!/usr/bin/perl

use CGI;
use DBI;

$q=new CGI;

print $q->header;

$dbh=DBI->connect('dbi:mysql:databasename','username','pwd');

#connect to the database ..
#enter your database name ,username and password to the connection string..

$sql="SELECT * FROM tblname";

print "Database Connectedn";

$sth = $dbh->prepare($sql)
or die "Can't prepare $sql: $dbh->errstrn";
#pass sql query to database handle..

$rv = $sth->execute
or die "can't execute the query: $sth->errstrn";

#execute your query


if ($rv==0){
#no rows fetched..

print "No Recordsn";
}else{
#record is available in your table

while(@row = $sth->fetchrow_array) {
print $row[0];
#print first column

}
}


hope this may help you to connect perl with mysql.

GOOD LUCK!!!!

------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #3  
Old May 20th, 2000, 04:15 PM
Adrian2 Adrian2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London, England
Posts: 251 Adrian2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
You can find out more about the Perl DBI module at http://www.symbolstone.org/technolo.../DBI/index.html

There is a very good sample chapter from the "official" DBI book, Programming the Perl DBI by Descartes & Bunce.
http://www.amazon.com/exec/obidos/A...0621359-3369603

Well worth buying if you're going to do a lot of this sort of thing. Look around the net, there should be a few good DBI tutorials too.


Reply With Quote
  #4  
Old May 31st, 2000, 04:28 PM
raosimha raosimha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 2 raosimha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There is an excellent tutorial for beginners on this topic at this site...
www.perl.com/pub/1999/10/DBI.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Connecting PERL with MySQL

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap