Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dbi::format(3) [redhat man page]

DBI::Format(3)						User Contributed Perl Documentation					    DBI::Format(3)

NAME
DBI::Format - A package for displaying result tables SYNOPSIS
# create a new result object $r = DBI::Format->new('var1' => 'val1', ...); # Prepare it for output by creating a header $r->header($sth, $fh); # In a loop, display rows while ($ref = $sth->fetchrow_arrayref()) { $r->row($ref); } # Finally create a trailer $r->trailer(); DESCRIPTION
THIS PACKAGE IS STILL VERY EXPERIMENTAL. THINGS WILL CHANGE. This package is used for making the output of DBI::Shell configurable. The idea is to derive a subclass for any kind of output table you might create. Examples are o a very simple output format as offered by DBI::neat_list(). "AVAILABLE SUBCLASSES". o a box format, as offered by the Data::ShowTable module. o HTML format, as used in CGI binaries o postscript, to be piped into lpr or something similar In the future the package should also support interactive methods, for example tab completion. These are the available methods: new(@attr) new(\%attr) (Class method) This is the constructor. You'd rather call a subclass constructor. The construcor is accepting either a list of key/value pairs or a hash ref. header($sth, $fh) (Instance method) This is called when a new result table should be created to display the results of the statement handle $sth. The (optional) argument $fh is an IO handle (or any object supporting a print method), usually you use an IO::Wrap object for STDIN. The method will query the $sth for its NAME, NUM_OF_FIELDS, TYPE, SCALE and PRECISION attributes and typically print a header. In general you should not assume that $sth is indeed a DBI statement handle and better treat it as a hash ref with the above attributes. row($ref) (Instance method) Prints the contents of the array ref $ref. Usually you obtain this array ref by calling $sth->fetchrow_arrayref(). trailer (Instance method) Once you have passed all result rows to the result package, you should call the trailer method. This method can, for example print the number of result rows. AVAILABLE SUBCLASSES
First of all, you can use the DBI::Format package itself: It's not an abstract base class, but a very simple default using DBI::neat_list(). Ascii boxes This subclass is using the Box mode of the Data::ShowTable module internally. Data::ShowTable(3). Raw Row is written without formating. Columns returned in comma or user defined separated list. String Row is written using a string format. Future releases will include th ability set the string format. AUTHOR AND COPYRIGHT
This module is Copyright (c) 1997, 1998 Jochen Wiedmann Am Eisteich 9 72555 Metzingen Germany Email: joe@ispsoft.de Phone: +49 7123 14887 The DBD::Proxy module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
DBI::Shell(3), DBI(3), dbish(1) perl v5.8.0 2002-11-29 DBI::Format(3)

Check Out this Related Man Page

DBD::Sponge(3pm)					User Contributed Perl Documentation					  DBD::Sponge(3pm)

NAME
DBD::Sponge - Create a DBI statement handle from Perl data SYNOPSIS
my $sponge = DBI->connect("dbi:Sponge:","","",{ RaiseError => 1 }); my $sth = $sponge->prepare($statement, { rows => $data, NAME => $names, %attr } ); DESCRIPTION
DBD::Sponge is useful for making a Perl data structure accessible through a standard DBI statement handle. This may be useful to DBD module authors who need to transform data in this way. METHODS
connect() my $sponge = DBI->connect("dbi:Sponge:","","",{ RaiseError => 1 }); Here's a sample syntax for creating a database handle for the Sponge driver. No username and password are needed. prepare() my $sth = $sponge->prepare($statement, { rows => $data, NAME => $names, %attr } ); o The $statement here is an arbitrary statement or name you want to provide as identity of your data. If you're using DBI::Profile it will appear in the profile data. Generally it's expected that you are preparing a statement handle as if a "select" statement happened. o $data is a reference to the data you are providing, given as an array of arrays. o $names is a reference an array of column names for the $data you are providing. The number and order should match the number and ordering of the $data columns. o %attr is a hash of other standard DBI attributes that you might pass to a prepare statement. Currently only NAME, TYPE, and PRECISION are supported. BUGS
Using this module to prepare INSERT-like statements is not currently documented. AUTHOR AND COPYRIGHT
This module is Copyright (c) 2003 Tim Bunce Documentation initially written by Mark Stosberg The DBD::Sponge module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. In particular permission is granted to Tim Bunce for distributing this as a part of the DBI. SEE ALSO
DBI perl v5.12.3 2007-09-26 DBD::Sponge(3pm)
Man Page