home *** CD-ROM | disk | FTP | other *** search
Wrap
<HTML> <HEAD> <TITLE>DBD::File - Base class for writing DBI drivers for plain files</TITLE> <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css"> <LINK REV="made" HREF="mailto:"> </HEAD> <BODY> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%> <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc"> <STRONG><P CLASS=block> DBD::File - Base class for writing DBI drivers for plain files</P></STRONG> </TD></TR> </TABLE> <A NAME="__index__"></A> <!-- INDEX BEGIN --> <UL> <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI> <LI><A HREF="#synopsis">SYNOPSIS</A></LI> <LI><A HREF="#description">DESCRIPTION</A></LI> <UL> <LI><A HREF="#metadata">Metadata</A></LI> <LI><A HREF="#driver private methods">Driver private methods</A></LI> </UL> <LI><A HREF="#todo">TODO</A></LI> <LI><A HREF="#known bugs">KNOWN BUGS</A></LI> <LI><A HREF="#author and copyright">AUTHOR AND COPYRIGHT</A></LI> <LI><A HREF="#see also">SEE ALSO</A></LI> </UL> <!-- INDEX END --> <HR> <P> <H1><A NAME="name">NAME</A></H1> <P>DBD::File - Base class for writing DBI drivers for plain files</P> <P> <HR> <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1> <UL> <LI>Linux</LI> <LI>Solaris</LI> <LI>Windows</LI> </UL> <HR> <H1><A NAME="synopsis">SYNOPSIS</A></H1> <PRE> use DBI; $dbh = DBI->connect("DBI:<A HREF="File:f_dir=/home/joe/csvdb"">File:f_dir=/home/joe/csvdb"</A>;) or die "Cannot connect: " . $DBI::errstr; $sth = $dbh->prepare("CREATE TABLE a (id INTEGER, name CHAR(10))") or die "Cannot prepare: " . $dbh->errstr(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); $sth->finish(); $dbh->disconnect();</PRE> <P> <HR> <H1><A NAME="description">DESCRIPTION</A></H1> <P>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.</P> <P>See <EM>DBI(3)</EM> for details on DBI, <A HREF="../../../SQL/Statement(3).html">the SQL::Statement(3) manpage</A> for details on SQL::Statement and <A HREF="../../../DBD/CSV(3).html">the DBD::CSV(3) manpage</A> or <A HREF="../../../DBD/IniFile(3).html">the DBD::IniFile(3) manpage</A> for example drivers.</P> <P> <H2><A NAME="metadata">Metadata</A></H2> <P>The following attributes are handled by DBI itself and not by DBD::File, thus they all work like expected:</P> <PRE> Active ActiveKids CachedKids CompatMode (Not used) InactiveDestroy Kids PrintError RaiseError Warn (Not used)</PRE> <P>The following DBI attributes are handled by DBD::File:</P> <DL> <DT><STRONG><A NAME="item_AutoCommit">AutoCommit</A></STRONG><BR> <DD> Always on <P></P> <DT><STRONG><A NAME="item_ChopBlanks">ChopBlanks</A></STRONG><BR> <DD> Works <P></P> <DT><STRONG><A NAME="item_NUM_OF_FIELDS">NUM_OF_FIELDS</A></STRONG><BR> <DD> Valid after <CODE>$sth-</CODE>execute> <P></P> <DT><STRONG><A NAME="item_NUM_OF_PARAMS">NUM_OF_PARAMS</A></STRONG><BR> <DD> Valid after <CODE>$sth-</CODE>prepare> <P></P> <DT><STRONG><A NAME="item_NAME">NAME</A></STRONG><BR> <DD> Valid after <CODE>$sth-</CODE>execute>; undef for Non-Select statements. <P></P> <DT><STRONG><A NAME="item_NULLABLE">NULLABLE</A></STRONG><BR> <DD> Not really working, always returns an array ref of one's, as DBD::CSV doesn't verify input data. Valid after <CODE>$sth-</CODE>execute>; undef for Non-Select statements. <P></P></DL> <P>These attributes and methods are not supported:</P> <PRE> bind_param_inout CursorName LongReadLen LongTruncOk</PRE> <P>Additional to the DBI attributes, you can use the following dbh attribute:</P> <DL> <DT><STRONG><A NAME="item_f_dir">f_dir</A></STRONG><BR> <DD> 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. <P></P></DL> <P> <H2><A NAME="driver private methods">Driver private methods</A></H2> <DL> <DT><STRONG><A NAME="item_data_sources">data_sources</A></STRONG><BR> <DD> The <A HREF="#item_data_sources"><CODE>data_sources</CODE></A> method returns a list of subdirectories of the current directory in the form ``DBI:CSV:f_dir=$dirname''. <P>If you want to read the subdirectories of another directory, use</P> <PRE> my($drh) = DBI->install_driver("CSV"); my(@list) = $drh->data_sources('f_dir' => '/usr/local/csv_data' );</PRE> <P></P> <DT><STRONG><A NAME="item_list_tables">list_tables</A></STRONG><BR> <DD> This method returns a list of file names inside $dbh->{'f_dir'}. Example: <PRE> my($dbh) = DBI->connect("DBI:CSV:f_dir=/usr/local/csv_data"); my(@list) = $dbh->func('list_tables');</PRE> <P>Note that the list includes all files contained in the directory, even those that have non-valid table names, from the view of SQL. See <A HREF="#creating and dropping tables">Creating and dropping tables</A> above.</P> <P></P></DL> <P> <HR> <H1><A NAME="todo">TODO</A></H1> <DL> <DT><STRONG><A NAME="item_Joins">Joins</A></STRONG><BR> <DD> The current version of the module works with single table SELECT's only, although the basic design of the SQL::Statement module allows joins and the likes. <P></P> <DT><STRONG><A NAME="item_Table_name_mapping">Table name mapping</A></STRONG><BR> <DD> Currently it is not possible to use files with names like <CODE>names.csv</CODE>. Instead you have to use soft links or rename files. As an alternative one might use, for example a dbh attribute 'table_map'. It might be a hash ref, the keys being the table names and the values being the file names. <P></P></DL> <P> <HR> <H1><A NAME="known bugs">KNOWN BUGS</A></H1> <UL> <LI> The module is using <A HREF="../../../lib/Pod/perlfunc.html#item_flock"><CODE>flock()</CODE></A> internally. However, this function is not available on all platforms. Using <A HREF="../../../lib/Pod/perlfunc.html#item_flock"><CODE>flock()</CODE></A> 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). <P></P></UL> <P> <HR> <H1><A NAME="author and copyright">AUTHOR AND COPYRIGHT</A></H1> <P>This module is Copyright (C) 1998 by</P> <PRE> Jochen Wiedmann Am Eisteich 9 72555 Metzingen Germany</PRE> <PRE> Email: joe@ispsoft.de Phone: +49 7123 14887</PRE> <P>All rights reserved.</P> <P>You may distribute this module under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.</P> <P> <HR> <H1><A NAME="see also">SEE ALSO</A></H1> <P><EM>DBI(3)</EM>, <A HREF="../../../Text/CSV_XS(3).html">the Text::CSV_XS(3) manpage</A>, <A HREF="../../../SQL/Statement(3).html">the SQL::Statement(3) manpage</A></P> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%> <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc"> <STRONG><P CLASS=block> DBD::File - Base class for writing DBI drivers for plain files</P></STRONG> </TD></TR> </TABLE> </BODY> </HTML>