Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

DBD::SQLite::VirtualTable::FileContent (3)

Name

DBD::SQLite::VirtualTable::FileContent - virtual table for viewing file contents

Synopsis

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 ...;

Description

User Contributed Perl Documentation
                                     DBD::SQLite::VirtualTable::FileContent(3)



NAME
       DBD::SQLite::VirtualTable::FileContent -- virtual table for viewing
       file contents

SYNOPSIS
       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 ...;

DESCRIPTION
       A "FileContent" virtual table is bound to some underlying source table,
       which has a column containing paths to files.  The virtual table
       behaves like a database view on the source table, with an added column
       which exposes the content from those files.

       This is especially useful as an "external content" to some fulltext
       table (see DBD::SQLite::Fulltext_search) : the index table stores some
       metadata about files, and then the fulltext engine can index both the
       metadata and the file contents.

PARAMETERS
       Parameters for creating a "FileContent" virtual table are specified
       within the "CREATE VIRTUAL TABLE" statement, just like regular column
       declarations, but with an '=' sign.  Authorized parameters are :

       "source"
           The name of the source table.  This parameter is mandatory. All
           other parameters are optional.

       "content_col"
           The name of the virtual column exposing file contents.  The default
           is "content".

       "path_col"
           The name of the column in "source" that contains paths to files.
           The default is "path".

       "expose"
           A comma-separated list (within double quotes) of source column
           names to be exposed by the virtual table. The default is "*", which
           means all source columns.

       "root"
           An optional root directory that will be prepended to the path
           column when opening files.

       "get_content"
           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 for example a function that would remove html
           tags. The hooked function is called like this :

             $file_content = $get_content->($path, $root);

AUTHOR
       Laurent Dami <dami@cpan.org>

COPYRIGHT AND LICENSE
       Copyright Laurent Dami, 2014.

       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.



ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+-------------------------------+
       |ATTRIBUTE TYPE |       ATTRIBUTE VALUE         |
       +---------------+-------------------------------+
       |Availability   | library/perl-5/dbd-sqlite-532 |
       +---------------+-------------------------------+
       |Stability      | Volatile                      |
       +---------------+-------------------------------+

NOTES
       Source code for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This software was built from source available at
       https://github.com/oracle/solaris-userland.  The original community
       source was downloaded from
       http://backpan.perl.org/authors/id/I/IS/ISHIGAKI/DBD-
       SQLite-1.70.tar.gz.

       Further information about this software can be found on the open source
       community website at https://github.com/DBD-SQLite/DBD-SQLite.



perl v5.32.0                      2022-06-28
                                     DBD::SQLite::VirtualTable::FileContent(3)