Skip to content

Integration

Heyang Zhou edited this page Oct 2, 2022 · 6 revisions

Preload mode

This is the "classical" mode and has the highest performance. But it requires the application to dynamically link SQLite.

Get the preload library from Releases.

# Follow the steps to create the database first: https://github.com/losfair/mvsqlite#try-it
export RUST_LOG=info MVSQLITE_DATA_PLANE="http://localhost:7000"
LD_PRELOAD=./libmvsqlite_preload.so my_sqlite_app

Patched libsqlite3.so

A patched libsqlite3.so that embeds mvSQLite is also provided. Feature and performance are equivalent to the preload mode. Get the file from Releases.

export RUST_LOG=info MVSQLITE_DATA_PLANE="http://localhost:7000"
LD_LIBRARY_PATH=/path/to/libsqlite3 my_sqlite_app

FUSE mode

This is an experimental feature. Data corruption is possible. DO NOT USE in production.

FUSE support was added in v0.1.14. This is a Linux-only integration mode inspired by LiteFS: the user mounts a virtual filesystem instead of injecting code into the application.

To use the FUSE mode, grab the mvsqlite-fuse binary from Releases (or build it yourself). Then run the FUSE service:

# Follow the steps to create the database first: https://github.com/losfair/mvsqlite#try-it
mkdir ./my_databases
RUST_LOG=info ./mvsqlite-fuse --data-plane http://localhost:7000 \
  --mountpoint ./my_databases \
  --namespaces "mydb=some_test_database"

The namespaces argument can also be set in the environment variable MVSQLITE_FUSE_NAMESPACES. It contains a comma-separated list of mappings from the virtual file name to the database namespace key.

Then, open the database with your favorite tools. There is no longer a dynamic-linking requirement.

sqlite3 ./my_databases/mydb

Caveats

Do not look inside the mountpoint with any other program except SQLite. It will not work.