|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
|
How can i connect PERL with MySQL
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
There is an excellent tutorial for beginners on this topic at this site...
www.perl.com/pub/1999/10/DBI.html |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Connecting PERL with MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|