There are several ways to use Dolt with Python. All require installing the dolt command line tool. Dolt's MySQL client/server support has the most development attention, but Dolt's CLI commands are a simpler way to get started with Python.

The sections below detail "sql-server" and "filesystem" interfaces for working with Dolt in Python. Refer to the CLI vs. server summary for a side by side comparison of how the data interface affects application flexibility.

More information regarding SQL-server use can be found in the Python SQL Client guide.

More information regarding Dolt CLI use in Python use can be found in the Doltpy guides. If interested in the source code, this file is responsible for most of basic commands. Most read/write source code is here.


Using a MySQL client driver to interact with a Dolt sql-server is the preferred way of using Dolt with Python. At production scale, Dolt is more practical as a Postgres or RDS substitute with additional versioning features.

Several existing Python client packages communicate with SQL servers and integrate with Dolt:

Practical examples using Dolt sql-server:


Contrary to the SQL-Server setup, Dolt's CLI is an all-in-one package and the easiest way to jump into experimenting. Dolt standalone contains all the tools needed to create and mutate databases.

If so inclined, you could use subprocess.Popen to directly call dolt shell commands from Python:

$ python3
>>> import subprocess
>>>["dolt", "clone", "max-hoffman/qm9"])
50,437 of 50,437 chunks complete. 0 chunks being downloaded currently.
CompletedProcess(args=['dolt', 'clone', 'max-hoffman/qm9'], returncode=0)

We built wrapper librares (doltpy, doltcli) to simplify this experience in Python:

$ pip install --user doltcli
$ python
>>> import doltcli as dolt
>>> dolt.Dolt.clone("max-hoffman/qm9")
Dolt(repo_dir='/Users/max-hoffman/qm9', print_output=False)

Dolt's Python libraries have their own heirarchy and usage patterns. doltcli is dependencyless and minimizes package conflicts for those getting started with Dolt locally. doltpy has more features to integrate with tools in the Python ecosystem. For example, doltpy.cli.write_pandas helps users import Pandas.DataFrame tables into Dolt:

$ pip install --user doltpy
$ python
>>> import pandas as pd
>>> import doltpy.cli as dolt
>>> from doltpy.cli.write import write_pandas
>>> df = pd.DataFrame({'name' : ['User 1', 'User 2', 'User 3']})
>>> db = dolt.Dolt.init()
>>> write_pandas(dolt=db, table="users", df=df, import_mode="create", primary_key=["name"])
>>> db.sql("select * from users where name = 'User 1'", result_format="json")
{'rows': [{'name': 'User 1'}]}