.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBD::SQLite::VirtualTable::FileContent 3pm" .TH DBD::SQLite::VirtualTable::FileContent 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME DBD::SQLite::VirtualTable::FileContent \-\- virtual table for viewing file contents .SH SYNOPSIS .IX Header "SYNOPSIS" Within Perl : .PP .Vb 1 \& $dbh\->sqlite_create_module(fcontent => "DBD::SQLite::VirtualTable::FileContent"); .Ve .PP Then, within SQL : .PP .Vb 8 \& 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 ...; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" A "FileContent" virtual table is bound to some underlying \fIsource table\fR, 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. .PP 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. .SH PARAMETERS .IX Header "PARAMETERS" Parameters for creating a \f(CW\*(C`FileContent\*(C'\fR virtual table are specified within the \f(CW\*(C`CREATE VIRTUAL TABLE\*(C'\fR statement, just like regular column declarations, but with an '=' sign. Authorized parameters are : .ie n .IP """source""" 4 .el .IP \f(CWsource\fR 4 .IX Item "source" The name of the \fIsource table\fR. This parameter is mandatory. All other parameters are optional. .ie n .IP """content_col""" 4 .el .IP \f(CWcontent_col\fR 4 .IX Item "content_col" The name of the virtual column exposing file contents. The default is \f(CW\*(C`content\*(C'\fR. .ie n .IP """path_col""" 4 .el .IP \f(CWpath_col\fR 4 .IX Item "path_col" The name of the column in \f(CW\*(C`source\*(C'\fR that contains paths to files. The default is \f(CW\*(C`path\*(C'\fR. .ie n .IP """expose""" 4 .el .IP \f(CWexpose\fR 4 .IX Item "expose" A comma-separated list (within double quotes) of source column names to be exposed by the virtual table. The default is \f(CW"*"\fR, which means all source columns. .ie n .IP """root""" 4 .el .IP \f(CWroot\fR 4 .IX Item "root" An optional root directory that will be prepended to the \fIpath\fR column when opening files. .ie n .IP """get_content""" 4 .el .IP \f(CWget_content\fR 4 .IX Item "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 : .Sp .Vb 1 \& $file_content = $get_content\->($path, $root); .Ve .SH AUTHOR .IX Header "AUTHOR" Laurent Dami .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright Laurent Dami, 2014. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.