Python loader for doltlite — Dolt version control through SQLite's drop-in API.
Project description
doltlite (Python)
A Python loader for doltlite — Dolt's version control through SQLite's drop-in API.
import doltlite # one-time bootstrap
import sqlite3
conn = sqlite3.connect("repo.db")
conn.execute("CREATE TABLE t(x INT)")
conn.execute("INSERT INTO t VALUES (1)")
conn.execute("SELECT dolt_commit('-A', '-m', 'init')")
import doltlite makes libdoltlite the active SQLite engine for the
current interpreter, so anything that uses the standard sqlite3 module
— including SQLAlchemy with sqlite:///... URLs — transparently
gains dolt_commit, dolt_branch, dolt_merge, dolt_log,
dolt_diff_<table>, and the other Dolt SQL functions and virtual tables.
Install
pip install doltlite
Wheels bundle a precompiled libdoltlite for macOS (arm64) and Linux
(x86_64, aarch64). No system-level setup required.
Intel Mac wheels aren't shipped in v0.11.x — GitHub's free-tier
macos-13 runners queue for hours and block releases. Intel Mac users
should build libdoltlite locally and use the DOLTLITE_LIB path below.
For development against a local checkout of doltlite, point
DOLTLITE_LIB at your built library instead:
DOLTLITE_LIB=/path/to/libdoltlite.dylib python3 your_script.py
Requirements
The package piggybacks on Python's stdlib sqlite3, which must load
SQLite as a shared extension at runtime. The following Pythons work:
- Distro / system Python (Linux)
- Homebrew Python (macOS, Linux)
- pyenv-built Python
- Conda Python
These do not work because their _sqlite3 is statically linked into
the interpreter:
- python-build-standalone interpreters — the default for
uv python install,mise, and Rye
If you use uv, target one of the supported Pythons explicitly:
uv venv --python /opt/homebrew/bin/python3 # or /usr/bin/python3
How the bootstrap works
Doltlite is a SQLite drop-in: it implements the same sqlite3_* C API
and adds Dolt-specific functions and virtual tables on top. To use it
from Python, libdoltlite has to be loaded ahead of the system libsqlite3
so its symbols win during the dynamic-link symbol-resolution pass that
Python's _sqlite3 module triggers when it's first imported.
The mechanics differ by platform:
Linux
ELF flat-namespace symbol resolution: if libdoltlite is loaded into the
process with RTLD_GLOBAL before _sqlite3 is loaded, its
sqlite3_* symbols enter the global namespace and the later
libsqlite3.so lookup finds them first.
import doltlite does ctypes.CDLL(libdoltlite_path, mode=ctypes.RTLD_GLOBAL) in this case — no re-exec required.
If sqlite3 was already imported before doltlite, that boat has
sailed: we fall back to re-execing the interpreter with LD_PRELOAD
set, so libdoltlite is loaded at process start.
macOS
macOS uses a two-level namespace: _sqlite3.so has an LC_LOAD_DYLIB
command bound to a specific libsqlite3.dylib path (e.g.
/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib). Plain dlopen /
ctypes.CDLL does not redirect that resolution, and
DYLD_INSERT_LIBRARIES alone doesn't either — the inserted library has
to have an install_name (LC_ID_DYLIB) that matches the path
_sqlite3.so was linked against.
import doltlite does:
- Detect that path via
otool -L $(python3 -c 'import _sqlite3; print(_sqlite3.__file__)'). - Copy libdoltlite to
$TMPDIR/.../libsqlite3.dylib(cached per (lib, mtime, install_name)). - Rewrite the shim's install_name with
install_name_tool -id <path>. - Re-exec the interpreter with
DYLD_INSERT_LIBRARIES=<shim>.
The two-level lookup then accepts the shim because the install_name matches.
This requires otool and install_name_tool — install Xcode Command
Line Tools (xcode-select --install) if missing.
Re-exec caveats
When a re-exec is required (macOS, or Linux-after-sqlite3-loaded), the
bootstrap calls os.execvpe with sys.argv. That means the
invocation must name a script file we can replay:
- ✅
python3 my_script.py - ✅
python3 -m my_package - ❌
python3 -c "import doltlite; ..."— code string isn't in argv - ❌ Interactive REPL / Jupyter — there's no script to re-exec
In the unsupported cases the bootstrap raises DoltliteLoadError with
a clear workaround: set DYLD_INSERT_LIBRARIES (macOS) or LD_PRELOAD
(Linux) yourself before starting Python.
API
import doltlite
# Side-effect import does the bootstrap automatically. Subsequent
# imports are no-ops thanks to a process-env marker.
# If you want to bootstrap explicitly (e.g. inside a function):
doltlite.bootstrap()
# Find where the loaded libdoltlite came from:
doltlite.libdoltlite_path() # absolute path
See also
- doltlite — the underlying SQLite + Dolt engine
- doltlite-sqlalchemy-getting-started — end-to-end SQLAlchemy demo (commits, branches, schema change, merge)
License
Apache License 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file doltlite-0.11.13.tar.gz.
File metadata
- Download URL: doltlite-0.11.13.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdbd8cb4c164131b5efb7758c1c31a03d524ebc38236d24fb211c7371cfd6a72
|
|
| MD5 |
4d86067f6117f964ee109189fb4e2cbd
|
|
| BLAKE2b-256 |
8b3a66d199676452c0f489d45923aa7d10b0285628962cd859bceff3560230b7
|
Provenance
The following attestation bundles were made for doltlite-0.11.13.tar.gz:
Publisher:
wheels.yml on dolthub/doltlite-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doltlite-0.11.13.tar.gz -
Subject digest:
bdbd8cb4c164131b5efb7758c1c31a03d524ebc38236d24fb211c7371cfd6a72 - Sigstore transparency entry: 1828397176
- Sigstore integration time:
-
Permalink:
dolthub/doltlite-python@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Branch / Tag:
refs/tags/v0.11.13 - Owner: https://github.com/dolthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file doltlite-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: doltlite-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fa255e1347e609ffb5baf7f2d59acca55eafa3f0e683e0de2de6d4d212e2ba3
|
|
| MD5 |
7b2b58d848a1b50d96218e7e2627f67e
|
|
| BLAKE2b-256 |
6e5ad080e26b3d6a1ac0402e3880118989dbeb25e07a1031673beccb463b769a
|
Provenance
The following attestation bundles were made for doltlite-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
wheels.yml on dolthub/doltlite-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doltlite-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0fa255e1347e609ffb5baf7f2d59acca55eafa3f0e683e0de2de6d4d212e2ba3 - Sigstore transparency entry: 1828397508
- Sigstore integration time:
-
Permalink:
dolthub/doltlite-python@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Branch / Tag:
refs/tags/v0.11.13 - Owner: https://github.com/dolthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file doltlite-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: doltlite-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 4.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f79590127579bbaa52cfa64ebc54e4b00a8fd9fb86ac78ec8a6c64de75117af5
|
|
| MD5 |
52172a92bbc69df76f5cb16d6172c51c
|
|
| BLAKE2b-256 |
b05e12ca740b803d4fed00de7ee4c261b783adc4b1b40a7cb7cef1fa163f5503
|
Provenance
The following attestation bundles were made for doltlite-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
wheels.yml on dolthub/doltlite-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doltlite-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f79590127579bbaa52cfa64ebc54e4b00a8fd9fb86ac78ec8a6c64de75117af5 - Sigstore transparency entry: 1828397421
- Sigstore integration time:
-
Permalink:
dolthub/doltlite-python@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Branch / Tag:
refs/tags/v0.11.13 - Owner: https://github.com/dolthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file doltlite-0.11.13-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: doltlite-0.11.13-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70e805290040f9819643332229189f4a819593fb728567c30cd74c82f2d58613
|
|
| MD5 |
2200fc21261b300a1d9388ae9e39725f
|
|
| BLAKE2b-256 |
7e5a1858f677cbaeba72944cda0088c39d1693434d2793e740b2e0f24b565ba9
|
Provenance
The following attestation bundles were made for doltlite-0.11.13-py3-none-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on dolthub/doltlite-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doltlite-0.11.13-py3-none-macosx_11_0_arm64.whl -
Subject digest:
70e805290040f9819643332229189f4a819593fb728567c30cd74c82f2d58613 - Sigstore transparency entry: 1828397313
- Sigstore integration time:
-
Permalink:
dolthub/doltlite-python@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Branch / Tag:
refs/tags/v0.11.13 - Owner: https://github.com/dolthub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1f14982c58b9dff4be13a829235a7e95e92c4b83 -
Trigger Event:
push
-
Statement type: