prady wrote:
hi all
i am creating a perl script which takes the input from the file to
create tables, inserting values into the database. As you all know the
only procedure for taking input from a file (using perl script) into
That is not correct.
MySQL database is through (?) place holders.
for example ,
$sth=$dbh->prepare
("INSERT INTO checkin (firstname, lastname, destination)
VALUES
(? , ? , ? )");
$rows=0;
open FILE, "passlist.txt" or die $!;
while (<FILE>) {
chomp;
($firstname, $lastname, $destination) = split(/:/);
$sth->execute($firstname, $lastname, $destination)
|| die "Couldn't insert record : $DBI::errstr";
Without the "prepare" you can write:
my $sql = qq/ INSERT INTO checkin SET firstname="$firstname",
lastname="$lastname", destination="$destination"/;
my $rc = $dbh->do{$sql};
$rows+=$sth->rows();
}
Where the passlist.txt hav the data in the format
Tim:Briggs:Glasgow
Simon:Cozens:Japan
Richard:Collins:Japan
Daniel:Maharry:Glasgow
Emma:Batch:Thailand
Now it is perfect that v can take input from a file...
P.S. : But i wanted to take INPUT that contains the info to create the
tables
Where
CREATE TABLE checkin (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(32) NOT NULL,
lastname VARCHAR(32) NOT NULL,
checkedin INTEGER,
numberofbags INTEGER,
destination VARCHAR(32) NOT NULL)
NOW I WANTED TO KNOW THE PROCEDURE FOR TAKING THE CODE AS INPUT FROM A
TEXT FILE & CREATE THE SPECIFIED TABLE
awaiting ur reply
Regards
prady
--
Mit freundlichem Gruß,
K. Jantzen
Tel.: +49-{0}7034-929651
Fax: +49-{0}7034-929652
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/