> CSV is an option - except that an awful lot of the data will need to be
> escaped out before it goes into the file, and I would rather only have to do
> when its rendered out to the browser.

> Unfortunately I'm not allowed to make use of the database - it is a
> requirement that this particular functionality can cope with the db not
> actually being there.

Sounds like you need DBD::CSV.

DBD::CSV will allow you to operate your text files in the same way that
you operate your database.  You can literally say:

$dbh = DBI->connect("DBI:mysql:database=whatever", "user", "pass") ## Your
                                                        # normal DB access.

$dbhcsv = DBI->connect("DBI:CSV:f_dir=/usr/data/csvstuff"); # Open the csv files

$sqlstring = "insert into mytable values (?,?,?,?,?,?);

$sth1 = $dbh->prepare($sqlstring);
$sthcsv = $dbhcsv->prepare($sqlstring);

#
#       Then, any operations you do on the database, you can do on the
#       CSV file... [0]
#

$sth1->execute(@args);
$sthcsv->execute(@args);

Regards,


Red

[0]     Although I wouldn't reccomend using it for large select-type queries
as with all plaintext files it won't scale.  Appending data to this type of
file seems to scale nicely.  It also means that if you were using these files
to restore your database if it loses everything retoration is as simple as
a read on one handle and a write on the other.

Reply via email to