Hi Guys, I am a beginner to perl.
I need a perl package which will perform basic DB operations like select , insert,update,delete operation MySql DB.
i Have a Mysql DB which resides on my local machine.DB Deatils are :
Localhost,MySql,DatabaseName:perltest, username:root,pwd:sierra,table:samples with coulms :id,name,phone
I am done with selecting the rows in DB. I need Sample code for inserting , updating and deleting . Please provide some basic infor regarding these. -
#!/usr/bin/perl -w
-
-
use DBI;
-
-
$dbh = DBI->connect('dbi:mysql:perltest','root','sierra')
-
-
or die "Connection Error: $DBI::errstr\n";
-
-
$sql = "select * from samples";
-
-
$sth = $dbh->prepare($sql);
-
-
$sth->execute
-
-
or die "SQL Error: $DBI::errstr\n";
-
-
while (@row = $sth->fetchrow_array) {
-
-
print "@row\n";
-
-
}
-
Similarly i Need code for Inserting and updating and deleting operations and all these functions as a package. Can guyz help me in how to proceed for these things.
You can mail me ur proceeding to this id EMAILS REMOVED
Thanks in Advance
Koti.
3 1866
Hi Guys, I am a beginner to perl.
I need a perl package which will perform basic DB operations like select , insert,update,delete operation MySql DB.
i Have a Mysql DB which resides on my local machine.DB Deatils are :
Localhost,MySql,DatabaseName:perltest, username:root,pwd:sierra,table:samples with coulms :id,name,phone
I am done with selecting the rows in DB. I need Sample code for inserting , updating and deleting . Please provide some basic infor regarding these. -
#!/usr/bin/perl -w
-
-
use DBI;
-
-
$dbh = DBI->connect('dbi:mysql:perltest','root','sierra')
-
-
or die "Connection Error: $DBI::errstr\n";
-
-
$sql = "select * from samples";
-
-
$sth = $dbh->prepare($sql);
-
-
$sth->execute
-
-
or die "SQL Error: $DBI::errstr\n";
-
-
while (@row = $sth->fetchrow_array) {
-
-
print "@row\n";
-
-
}
-
Similarly i Need code for Inserting and updating and deleting operations and all these functions as a package. Can guyz help me in how to proceed for these things.
You can mail me ur proceeding to this id EMAILS REMOVED
Thanks in Advance
Koti.
The examples will be available in the documentation for DBD::MySQL in search.cpan.org.
You may go through this link
Please DO NOT include any email addresses or contact information in the technical forums. This information is easily scraped by web spiders. This policy exists for your protection. Please read the Posting Guidelines for this site so you are aware of what to and not to do.
Regards,
Moderator
well first off this question isn't related to Perl, but to mysql statements
for example look at the var $sql see what has changed from the code you posted. - use DBI;
-
-
$dbh = DBI->connect('dbi:mysql:perltest','root','sierra')
-
-
or die "Connection Error: $DBI::errstr\n";
-
-
$sql = "INSERT INTO $tablename (custid, name, repcode, state, contact, phone, warn) VALUES ('$customerid','$customername','$repcode','$state','$contact','$tel','$warnnote') ";
-
-
$sth = $dbh->prepare($sql);
-
-
$sth->execute
-
-
or die "SQL Error: $DBI::errstr\n";
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
I have a text file of data in a file (add2db.txt) where the entries are
already entered on separate lines in the following form:
INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
|
by: Atz |
last post by:
Hi to all !
Im using MySql front and PHP 5 for some web shop.
I didn't try it so far but i guess that the online data insertation ( accept
costs and time ) should be the same process like for...
|
by: Pugi! |
last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get
the following problem when connecting to mysql through a browser
(phpMyAdmin):
:
#2002 Can't connect to local MySQL...
|
by: MLH |
last post by:
Using MS Access, I have attached to MySQL servers in other states
and other countries on the other side of my router. But when I use the
MySQL ODBC driver 3.51 to connect to a MySQL server on my...
|
by: Ian Davies |
last post by:
Hello all
The following code allows me to connect to a local MySQL database on my pc
from a VB6 project.
****************************************************************************
**
Dim...
|
by: phillip.s.powell |
last post by:
We're looking at a GUI interface for our MySQL DB and I am interested
in MySQL Administrator, however, one of our requirements is to be able
to import/export databases. Is this possible or do I...
|
by: bballr |
last post by:
I have a problem that I'm not sure if it can be done. I'm trying to
use the MySQL C API to be able to use a normal sql insert statement
that will send the data or file to a directory and NOT the...
|
by: refugeedeveloper |
last post by:
Im trying to use the mysql_connect command to connect to the mysql
server from a php file.
What is the HOST name I should use?
The tutorial book I have uses "localhost" but Im installing the...
|
by: josie23 |
last post by:
Egad,
I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile.
But, I've been trying to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |