perl with mysql which takes a file as a input that contains t he info to create the tables
- From: prady184u@xxxxxxxxx (Prady)
- Date: Thu, 15 Nov 2007 22:56:10 -0800 (PST)
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
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";
$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...
What exactly i wanted to do is..
to take a input from a file of format :
INPUT.txt :
Details> name , id INTEGER, area VARCHAR(32)
prady,2039,india
sandy,2398,india
sam,1234,aussie
Rob,2345,Eng
extraDetails>name1 VARCHAR(12), name2 VARCHAR(12)
prady,sandy
sandy,Rob
Rob,sam
sam,prady
in the above text format u can find two tables one is Details> & the
other is extraDetails>
so i wanted to take the line Details> for creating table , & the
values below it for inserting into the table. similarly the second
shud be find out (extraDetails) & those values shud be inserted in to
its table
& one more script the other way round like by getting the
(retrieving) the data from the mysql database using some queries &
creating a file in the above specified INPUT.txt format.
could u please help me in this regard
thanx
Regards
Prady
.
- Prev by Date: perl with mysql which takes a file as a input that contains t he info to create the tables
- Next by Date: PAR-PP package on Windows
- Previous by thread: Re: perl with mysql which takes a file as a input that contains t he info to create the tables
- Next by thread: PAR-PP package on Windows
- Index(es):
Relevant Pages
|
|