Tcl VFS integration for Sqlite3
It's a project in its alpha (or pre-alpha) stage.
Problem that I'm trying to solve
Sqlite is a great database engine, especially for embedding into
applications. Starkit is a nice technology for Tcl-based application
deployment. There is, however, one bad thing about using them
together: application packed into a starkit (or other similar
container like FreeWrap) has its files in the virtual file system,
supported by the Tcl VFS layer. Sqlite doesn't know anything about Tcl
VFS layer, and can't work with databases wrapped into a starkit.
It's fixable. It's easy
Sqlite has its own VFS layer, supporting multiple pluggable
filesystems at once. It's not entirely the same as the Tcl VFS layer,
but for a large subset of file operations, mapping from sqlite VFS
method to Tcl API is pretty straightforward.
All I have to do is writing the code forwarding sqlite requests to Tcl
filesystem API, using Tcl functions instead of the operating system
file management functions.
The code: its status and location
- http://www.siftsoft.com/inprogress/tclsqlitevfs0_1.zip contains the
source code of a Tcl extension, that should be linked dynamically
against sqlite3 library and loaded into the Tcl interpreter that
will be using the same library for database access. No elaborate
build system yet: just a one-line shell file that build a shared
library on my Debian GNU/Linux system with Gcc.
- http://www.siftsoft.com/inprogress/tclsqlitevfs0_2_demo.zip is a
starpack for windows, containing sqlite3622.dll with my ``vfs
brigde'' included. Embedded main.tcl script opens a database inside
the starpack and outputs a query result. The DLL may be extracted
by anyone who knows how to use SDX, and reused in other starkits.
Status overview
Works, as far as I've tested
- read access to databases inside a Starkit/Starpack;
- amd64/Linux, x86/Linux and x86/Windows builds;
- passing files on the native filesystem to the `native' sqlite VFS
driver.
Not tested but may work
- writing to databases on VFS's that support it.
Not done yet, and rather easy to do
- prepare TEA-based package for cross-platform building the extension;
- automate building of custom sqlite3 library with the extension
included;
- make a compile-time option for registering non-default VFS instead
of overriding the default one.
Not done and probably impossible
- implementing synchronization and locking primitives on top of Tcl VFS's
Licence etc.
This code is public domain.
A. Kovalenko, Tue Feb 23 04:04:21 UTC 2010