Linux Blog

DBD::File

NAME

DBD::File - Base class for writing DBI drivers

SYNOPSIS

This module is a base class for writing other DBDs.
It is not intended to function as a DBD itself.
If you want to access flatfiles, use DBD::AnyData, or DBD::CSV,
(both of which are subclasses of DBD::File).

DESCRIPTION

The DBD::File module is not a true DBI driver, but an abstract
base class for deriving concrete DBI drivers from it. The implication is,
that these drivers work with plain files, for example CSV files or
INI files. The module is based on the SQL::Statement module, a simple
SQL engine.

See DBI for details on DBI, SQL::Statement for details on
SQL::Statement and DBD::CSV or DBD::IniFile for example
drivers.

Metadata

The following attributes are handled by DBI itself and not by DBD::File,
thus they all work like expected:

Additional to the DBI attributes, you can use the following dbh
attribute:

f_dir

This attribute is used for setting the directory where CSV files are
opened. Usually you set it in the dbh, it defaults to the current
directory (``.''). However, it is overwritable in the statement handles.

Driver private methods

data_sources

The "data_sources" method returns a list of subdirectories of the current
directory in the form ``DBI:CSV:f_dir=$dirname''.

Note that the list includes all files contained in the directory, even
those that have non-valid table names, from the view of SQL.

KNOWN BUGS

*

The module is using flock() internally. However, this function is not
available on all platforms. Using flock() is disabled on MacOS and
Windows 95: There's no locking at all (perhaps not so important on
MacOS and Windows 95, as there's a single user anyways).