MAN page from OpenSuSE perl-DBD-SQLite-1.54-42.1.x86_64.rpm
Section: User Contributed Perl Documentation (3)
DBD::SQLite::VirtualTable::FileContent -- virtual table for viewing file contents
Within Perl :
$dbh->sqlite_create_module(fcontent => "DBD::SQLite::VirtualTable::FileContent");
Then, within SQL :
CREATE VIRTUAL TABLE tbl USING fcontent( source = src_table, content_col = content, path_col = path, expose = "path, col1, col2, col3", -- or "*" root = "/foo/bar" get_content = Foo::Bar::read_from_file ); SELECT col1, path, content FROM tbl WHERE ...;
A ``FileContent'' virtual table is bound to some underlying sourcetable
, which has a column containing paths to files. The virtualtable behaves like a database view on the source table, with an addedcolumn which exposes the content from those files.
This is especially useful as an ``external content'' to somefulltext table (see DBD::SQLite::Fulltext_search) : the indextable stores some metadata about files, and then the fulltext enginecan index both the metadata and the file contents.
Parameters for creating a "FileContent"
virtual table arespecified within the "CREATE VIRTUAL TABLE"
statement, justlike regular column declarations, but with an '=' sign.Authorized parameters are :
- The name of the source table.This parameter is mandatory. All other parameters are optional.
- The name of the virtual column exposing file contents.The default is "content".
- The name of the column in "source" that contains paths to files.The default is "path".
- A comma-separated list (within double quotes) of source column namesto be exposed by the virtual table. The default is "*", which meansall source columns.
- An optional root directory that will be prepended to the path columnwhen opening files.
- Fully qualified name of a Perl function for reading file contents.The default implementation just slurps the entire file into a string;but this hook can point to more sophisticated implementations, like forexample a function that would remove html tags. The hooked function iscalled like this :
$file_content = $get_content->($path, $root);
Laurent Dami <damiAATTcpan.org>
COPYRIGHT AND LICENSE
Copyright Laurent Dami, 2014.
This library is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.
- COPYRIGHT AND LICENSE
This document was created byman2html,using the manual pages.