SlideShare ist ein Scribd-Unternehmen logo
1 von 13
05.09.2014 - Page 1 
Département 
Office 
Sqlite Virtual Tables 
written in Perl 
Swiss Perl Workshop 2014 
laurent.dami@justice.ge.ch 
Etat de Genève, Pouvoir Judiciaire 
Département 
Office
What is SQLite 
• Relational Database Engine in a C software library 
–  SQL support, including foreign keys constraints, transactions, etc. 
– Also fulltext support 
– Self-contained 
• File-based 
–  No server, no sockets, zero configuration 
• Extensible 
–  can add user-defined functions, aggregate functions, etc. 
Great for tests 
Great for embedded devices 
 "the most widely deployed database engine in the world" 
(smartphones, Firefox, etc.) http://www.sqlite.org
SQLite and Perl 
• DBD::SQLite driver 
– Contains the whole SQLite source (no external dependency) 
– Regularly updated 
• Usage : 
use DBI; 
my $dsn = "dbi:SQLite:dbname=$dbfile"; 
my $dbh = DBI->connect($dsn,"","", %options);
Tied variables in Perl 
my %regular_hash 
Perl Core 
implementation 
tie my %foo_hash, 'Tie::Hash::Foo'; 
Tie::Hash::Foo 
+TIEHASH 
+FETCH 
+STORE 
...
Virtual tables in SQLite 
CREATE TABLE Foo(...) 
SQLite core 
implementation 
CREATE VIRTUAL TABLE Bar 
USING foobar (....) 
Foobar.c 
+xOpen 
+xNext 
+xEof 
+xColumn 
... 
C code 
Virtual tables in DBD::Sqlite '1.43_08' 
# register the virtual table module within sqlite 
$dbh->sqlite_create_module(mod_name => 
"DBD::SQLite::VirtualTable::Subclass"); 
# create a virtual table 
$dbh->do("CREATE VIRTUAL TABLE vtbl " 
"USING mod_name(arg1, arg2, ...)") 
Will be passed to 
the CREATE() 
method 
# use it as any regular table 
my $sth = $dbh->prepare("SELECT * FROM vtbl ...");
Implementing a virtual table 
DBD::SQLite::VirtualTable DBD::SQLite::VirtualTable::Cursor 
MyVTab MyVTab::Cursor 
+CREATE 
+BEST_INDEX 
... 
+FILTER 
+NEXT 
+EOF 
+COLUMN 
...
Builtin 1: VirtualTable::FileContent 
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 ...; 
CREATE VIRTUAL TABLE fts USING fts4( 
content="tbl", tokenize=unicode61);
FileContent + FTS4 
Virtual (FTS4, C code) Virtual (FileContent, Perl) 
C1 Content 
C1 C2 Path 
get_content() 
C1 Content 
Regular table 
FTS4 internals 
Filesystem
Builtin 2: VirtualTable::PerlData 
CREATE VIRTUAL TABLE atbl USING perl( 
foo, bar, etc, 
arrayrefs="some::global::var::aref") 
CREATE VIRTUAL TABLE htbl USING perl( 
foo, bar, etc, 
hashrefs="some::global::var::href") 
CREATE VIRTUAL TABLE ctbl USING perl( 
single_col, 
colref="some::global::var::ref")
Hashrefs example 
use Unicode::UCD 'charinfo'; 
our $chars = [map {charinfo($_)} 0x300..0x400]; 
CREATE VIRTUAL TABLE charinfo USING perl( 
code, name, block, script, category, 
hashrefs="main::chars"); 
SELECT * FROM charinfo 
WHERE script='Greek' 
AND name LIKE '%SIGMA%'
Colref example 
# perl 
our $values = @ARGV; 
# SQL 
CREATE VIRTUAL TABLE iarray USING perl(i INT, 
colref="main::values"); 
SELECT * FROM some_table WHERE some_col IN iarray; 
# BEWARE! 
INSERT INTO iarray VALUES (99); # pushes in @ARGV
Go and try 
• https://metacpan.org/source/ISHIGAKI/DBD-SQLite- 
1.43_08 
• https://github.com/DBD-SQLite/DBD-SQLite

Weitere ähnliche Inhalte

Was ist angesagt?

Rupy2012 ArangoDB Workshop Part2
Rupy2012 ArangoDB Workshop Part2Rupy2012 ArangoDB Workshop Part2
Rupy2012 ArangoDB Workshop Part2
ArangoDB Database
 

Was ist angesagt? (20)

Exported resources design patterns
Exported resources design patternsExported resources design patterns
Exported resources design patterns
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Polyglot Persistence
Polyglot PersistencePolyglot Persistence
Polyglot Persistence
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
 
XFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in thereXFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in there
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
Database2011 MySQL Sharding
Database2011 MySQL ShardingDatabase2011 MySQL Sharding
Database2011 MySQL Sharding
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Rupy2012 ArangoDB Workshop Part2
Rupy2012 ArangoDB Workshop Part2Rupy2012 ArangoDB Workshop Part2
Rupy2012 ArangoDB Workshop Part2
 
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbAirbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
 
lab56_db
lab56_dblab56_db
lab56_db
 
D7dev
D7devD7dev
D7dev
 
XQuery in the Cloud
XQuery in the CloudXQuery in the Cloud
XQuery in the Cloud
 
Cassandra 3 new features @ Geecon Krakow 2016
Cassandra 3 new features  @ Geecon Krakow 2016Cassandra 3 new features  @ Geecon Krakow 2016
Cassandra 3 new features @ Geecon Krakow 2016
 
Drupal 8 configuration management
Drupal 8 configuration managementDrupal 8 configuration management
Drupal 8 configuration management
 
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksMigrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
 
Hive @ Bucharest Java User Group
Hive @ Bucharest Java User GroupHive @ Bucharest Java User Group
Hive @ Bucharest Java User Group
 
Visualize Solr Data with Banana: Presented by Andrew Thanalertvisuti, Lucidworks
Visualize Solr Data with Banana: Presented by Andrew Thanalertvisuti, LucidworksVisualize Solr Data with Banana: Presented by Andrew Thanalertvisuti, Lucidworks
Visualize Solr Data with Banana: Presented by Andrew Thanalertvisuti, Lucidworks
 

Andere mochten auch (6)

perl language update
perl language updateperl language update
perl language update
 
2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情
 
JSON, JSON::PP, and more
JSON, JSON::PP, and moreJSON, JSON::PP, and more
JSON, JSON::PP, and more
 
10年モノ熟成Perlとの付き合い方
10年モノ熟成Perlとの付き合い方10年モノ熟成Perlとの付き合い方
10年モノ熟成Perlとの付き合い方
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)
 
Infrastructure of Pathtraq
Infrastructure of PathtraqInfrastructure of Pathtraq
Infrastructure of Pathtraq
 

Ähnlich wie Sqlite virtual-tables written in Perl

android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
Cosmos, Big Data GE Implementation
Cosmos, Big Data GE ImplementationCosmos, Big Data GE Implementation
Cosmos, Big Data GE Implementation
FIWARE
 

Ähnlich wie Sqlite virtual-tables written in Perl (20)

Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbai
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
 
Better Data Persistence on Android
Better Data Persistence on AndroidBetter Data Persistence on Android
Better Data Persistence on Android
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Advance Mobile Application Development class 01
Advance Mobile Application Development class 01Advance Mobile Application Development class 01
Advance Mobile Application Development class 01
 
Swift core
Swift coreSwift core
Swift core
 
20141011 mastering mysqlnd
20141011 mastering mysqlnd20141011 mastering mysqlnd
20141011 mastering mysqlnd
 
android sqlite
android sqliteandroid sqlite
android sqlite
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
 
Cosmos, Big Data GE implementation in FIWARE
Cosmos, Big Data GE implementation in FIWARECosmos, Big Data GE implementation in FIWARE
Cosmos, Big Data GE implementation in FIWARE
 
Cosmos, Big Data GE Implementation
Cosmos, Big Data GE ImplementationCosmos, Big Data GE Implementation
Cosmos, Big Data GE Implementation
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Cordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITECordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITE
 
More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
 
Spark Summit EU 2015: Spark DataFrames: Simple and Fast Analysis of Structure...
Spark Summit EU 2015: Spark DataFrames: Simple and Fast Analysis of Structure...Spark Summit EU 2015: Spark DataFrames: Simple and Fast Analysis of Structure...
Spark Summit EU 2015: Spark DataFrames: Simple and Fast Analysis of Structure...
 
DBD::SQLite
DBD::SQLiteDBD::SQLite
DBD::SQLite
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 

Mehr von Laurent Dami

DBIx::Class vs. DBix::DataModel
DBIx::Class vs. DBix::DataModelDBIx::Class vs. DBix::DataModel
DBIx::Class vs. DBix::DataModel
Laurent Dami
 

Mehr von Laurent Dami (9)

PowerPivot_model_Geneva_Justice_20230531.pptx
PowerPivot_model_Geneva_Justice_20230531.pptxPowerPivot_model_Geneva_Justice_20230531.pptx
PowerPivot_model_Geneva_Justice_20230531.pptx
 
Studying geneva real estate prices using perl grammars
Studying geneva real estate prices using perl grammarsStudying geneva real estate prices using perl grammars
Studying geneva real estate prices using perl grammars
 
Yapceu2015 geneva courts
Yapceu2015 geneva courtsYapceu2015 geneva courts
Yapceu2015 geneva courts
 
DBIx::Class vs. DBix::DataModel
DBIx::Class vs. DBix::DataModelDBIx::Class vs. DBix::DataModel
DBIx::Class vs. DBix::DataModel
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail
 
Gestion documentaire pour les tribunaux genevois
Gestion documentaire pour les tribunaux genevoisGestion documentaire pour les tribunaux genevois
Gestion documentaire pour les tribunaux genevois
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Emacs, a performant IDE for Perl
Emacs, a performant IDE for PerlEmacs, a performant IDE for Perl
Emacs, a performant IDE for Perl
 
Managing Geneva's law courts, from Cobol to Perl
Managing Geneva's law courts, from Cobol to PerlManaging Geneva's law courts, from Cobol to Perl
Managing Geneva's law courts, from Cobol to Perl
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

Sqlite virtual-tables written in Perl

  • 1. 05.09.2014 - Page 1 Département Office Sqlite Virtual Tables written in Perl Swiss Perl Workshop 2014 laurent.dami@justice.ge.ch Etat de Genève, Pouvoir Judiciaire Département Office
  • 2. What is SQLite • Relational Database Engine in a C software library –  SQL support, including foreign keys constraints, transactions, etc. – Also fulltext support – Self-contained • File-based –  No server, no sockets, zero configuration • Extensible –  can add user-defined functions, aggregate functions, etc. Great for tests Great for embedded devices  "the most widely deployed database engine in the world" (smartphones, Firefox, etc.) http://www.sqlite.org
  • 3. SQLite and Perl • DBD::SQLite driver – Contains the whole SQLite source (no external dependency) – Regularly updated • Usage : use DBI; my $dsn = "dbi:SQLite:dbname=$dbfile"; my $dbh = DBI->connect($dsn,"","", %options);
  • 4. Tied variables in Perl my %regular_hash Perl Core implementation tie my %foo_hash, 'Tie::Hash::Foo'; Tie::Hash::Foo +TIEHASH +FETCH +STORE ...
  • 5. Virtual tables in SQLite CREATE TABLE Foo(...) SQLite core implementation CREATE VIRTUAL TABLE Bar USING foobar (....) Foobar.c +xOpen +xNext +xEof +xColumn ... C code 
  • 6. Virtual tables in DBD::Sqlite '1.43_08' # register the virtual table module within sqlite $dbh->sqlite_create_module(mod_name => "DBD::SQLite::VirtualTable::Subclass"); # create a virtual table $dbh->do("CREATE VIRTUAL TABLE vtbl " "USING mod_name(arg1, arg2, ...)") Will be passed to the CREATE() method # use it as any regular table my $sth = $dbh->prepare("SELECT * FROM vtbl ...");
  • 7. Implementing a virtual table DBD::SQLite::VirtualTable DBD::SQLite::VirtualTable::Cursor MyVTab MyVTab::Cursor +CREATE +BEST_INDEX ... +FILTER +NEXT +EOF +COLUMN ...
  • 8. Builtin 1: VirtualTable::FileContent 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 ...; CREATE VIRTUAL TABLE fts USING fts4( content="tbl", tokenize=unicode61);
  • 9. FileContent + FTS4 Virtual (FTS4, C code) Virtual (FileContent, Perl) C1 Content C1 C2 Path get_content() C1 Content Regular table FTS4 internals Filesystem
  • 10. Builtin 2: VirtualTable::PerlData CREATE VIRTUAL TABLE atbl USING perl( foo, bar, etc, arrayrefs="some::global::var::aref") CREATE VIRTUAL TABLE htbl USING perl( foo, bar, etc, hashrefs="some::global::var::href") CREATE VIRTUAL TABLE ctbl USING perl( single_col, colref="some::global::var::ref")
  • 11. Hashrefs example use Unicode::UCD 'charinfo'; our $chars = [map {charinfo($_)} 0x300..0x400]; CREATE VIRTUAL TABLE charinfo USING perl( code, name, block, script, category, hashrefs="main::chars"); SELECT * FROM charinfo WHERE script='Greek' AND name LIKE '%SIGMA%'
  • 12. Colref example # perl our $values = @ARGV; # SQL CREATE VIRTUAL TABLE iarray USING perl(i INT, colref="main::values"); SELECT * FROM some_table WHERE some_col IN iarray; # BEWARE! INSERT INTO iarray VALUES (99); # pushes in @ARGV
  • 13. Go and try • https://metacpan.org/source/ISHIGAKI/DBD-SQLite- 1.43_08 • https://github.com/DBD-SQLite/DBD-SQLite