Skip to main content

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:

  1. Detect that path via otool -L $(python3 -c 'import _sqlite3; print(_sqlite3.__file__)').
  2. Copy libdoltlite to $TMPDIR/.../libsqlite3.dylib (cached per (lib, mtime, install_name)).
  3. Rewrite the shim's install_name with install_name_tool -id <path>.
  4. 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

License

Apache License 2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doltlite-0.11.54.tar.gz (13.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

doltlite-0.11.54-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

doltlite-0.11.54-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

doltlite-0.11.54-py3-none-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file doltlite-0.11.54.tar.gz.

File metadata

  • Download URL: doltlite-0.11.54.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for doltlite-0.11.54.tar.gz
Algorithm Hash digest
SHA256 560aaf9baf759281009db300b26857b7b00501e309d156d6796ead6b9f234e1a
MD5 c07a2b296b1d3ed49cc881ce98433504
BLAKE2b-256 c21a02bcd476e865d31b7505341678e6a76a0a61ef2a5502c27aaac108156920

See more details on using hashes here.

Provenance

The following attestation bundles were made for doltlite-0.11.54.tar.gz:

Publisher: wheels.yml on dolthub/doltlite-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file doltlite-0.11.54-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for doltlite-0.11.54-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae3b454511a953107688058c50b84b83f09926edf84b14e04edc145b6a30bbbf
MD5 0d51c8cce46aeba4ca49df6c11187fbb
BLAKE2b-256 5c1cdcbfc22748d8023ef12d85dec970226d17a577d57ccfe7347a93e6344ae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for doltlite-0.11.54-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on dolthub/doltlite-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file doltlite-0.11.54-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for doltlite-0.11.54-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4cd055c2b45b26dd80faf3af457ceaef958e7f6d177f893b851b6b0b302f3f1b
MD5 25b115f4b30b5701dddb701e42da1782
BLAKE2b-256 ab2a0ee3eed35eb36d630e580a313165759fffe027ce95cae232b4520b19e6f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for doltlite-0.11.54-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on dolthub/doltlite-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file doltlite-0.11.54-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for doltlite-0.11.54-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 921dc0a61873a07c5fa914bebf85728bbd753ef982edd630b58bf78fa84bf663
MD5 50b79658667ac7c5da1d3d8ca9a44710
BLAKE2b-256 75f1f1ee15c7265cd860d9e735aed527aee817fbba4757335b0d4392704edc56

See more details on using hashes here.

Provenance

The following attestation bundles were made for doltlite-0.11.54-py3-none-macosx_11_0_arm64.whl:

Publisher: wheels.yml on dolthub/doltlite-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.50.4

4 files

0.50.3

4 files

0.50.2

4 files

0.50.1

4 files

0.50.0

4 files

0.11.57

4 files

0.11.56

4 files

0.11.55

4 files

This release

0.11.54 This release

4 files

0.11.53

4 files

0.11.52

4 files

0.11.51

4 files

0.11.50

4 files

0.11.49

4 files

0.11.48

4 files

0.11.47

4 files

0.11.46

4 files

0.11.45

4 files

0.11.44

4 files

0.11.43

4 files

0.11.42

4 files

0.11.41

4 files

0.11.40

4 files

0.11.39

4 files

0.11.38

4 files

0.11.37

4 files

0.11.36

4 files

0.11.35

4 files

0.11.34

4 files

0.11.33

4 files

0.11.32

4 files

0.11.31

4 files

0.11.30

4 files

0.11.29

4 files

0.11.28

4 files

0.11.27

4 files

0.11.26

4 files

0.11.25

4 files

0.11.24

4 files

0.11.23

4 files

0.11.22

4 files

0.11.21

4 files

0.11.20

4 files

0.11.19

4 files

0.11.18

4 files

0.11.17

4 files

0.11.16

4 files

0.11.15

4 files

0.11.14

4 files

0.11.13

4 files

0.11.8

4 files

0.11.2

4 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page