Click to See Complete Forum and Search --> : How To Save Data to a SQL database using Perl??


Winglys
03-17-2003, 07:02 PM
Hi everyone,
How To Save Data to a SQL database using Perl??
Can someone show me the code or ways to do so?
thanks

Jona
03-17-2003, 07:35 PM
That was my next question... I'll wait for the answer. :) Thanks. :D

tonis
03-24-2003, 03:24 PM
Go to your local library and get a copy of CGI Programming 101 there is an awesome chapter on this (Chapter 18)


or go to cgi101.com and look at some source code if u think that will be enough to help you

Nedals
03-24-2003, 06:29 PM
#!/usr/local/bin/perl
use DBI;

my $db_name = "database name";
my $db_uid = "userid";
my $db_pwd = "password";
my $dsn = "DBI:mysql:$db_name";
my $dbh = DBI->connect($dsn,$db_uid,$db_pwd);
...
# Basic method. There are a others
$query = "INSERT INTO TableName VALUES('$item1', .. same number of (quoted) items as columns in your table ..')";
$dbh->do($query);
...
$dbh->disconnect(); # when you are done using the database
exit;