Dolt – Git for Data
Dolt is a SQL database that you can fork, clone, branch, merge, push and pull just like a Git repository.
Connect to Dolt just like any MySQL database to read or modify schema and data. Version control functionality is exposed in SQL via system tables, functions, and procedures.
Or, use the Git-like command line interface to import CSV files, commit your changes, push them to a remote, or merge your teammate's changes. All the commands you know for Git work exactly the same for Dolt.
Git versions files. Dolt versions tables. It's like Git and MySQL had a baby.
We also built DoltHub, a place to share Dolt databases. We host public data for free. If you want to host your own version of DoltHub, we have DoltLab. If you want us to run a Dolt server for you, we have Hosted Dolt.
Prefer Postgres instead of MySQL? Try Doltgres, now in its Beta release.
Join us on Discord to say hi and ask questions, or check out our roadmap to see what we're building next.
Lots of things! Dolt is a generally useful tool with countless applications. But if you want some ideas, here's how people are using it so far.
Dolt powers Beads and Gas Town. It's the best database for agent memory, especially as you move up the ladder to multi-agent and multi-machine workflows.
The dolt CLI has the same commands as git, with some extras.
…Dolt is a single ~103 megabyte program.
dolt $ du -h /Users/timsehn/go/bin/dolt
103M /Users/timsehn/go/bin/doltIt's really easy to install. Download it and put it on your PATH.
We have a bunch of ways to make this even easier for most platforms.
To install on Linux or Mac based systems run this command in your terminal:
sudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash'This will download the latest dolt release and put it in
/usr/local/bin/, which is probably on your $PATH.
The install script needs sudo in order to put dolt in /usr/local/bin. If you don't have root
privileges or aren't comfortable running a script with them, you can download the dolt binary
for your platform from the latest release, unzip it,
and put the binary somewhere on your $PATH.
Dolt is packaged in the official repositories for Arch Linux.
pacman -S doltDolt is on Homebrew, updated every release.
brew install doltOn macOS, Dolt can also be installed via a community-managed port via MacPorts:
sudo port install doltDownload the latest Microsoft Installer (.msi file) in
releases and run
it.
For information on running on Windows, see here.
You can install dolt using Chocolatey:
choco install doltThere are following official Docker images for Dolt:
dolthub/dolt for running Dolt
as CLI tool.dolthub/dolt-sql-server for running Dolt in server mode.Make sure you have Go installed, and that go is in your path. Dolt has a dependency on cgo, so you will need a working C compiler and toolchain as well.
Clone this repository and cd into the go directory. Then run:
go install ./cmd/doltThe output will be in $GOPATH/bin, which defaults to ~/go/bin. To test your build, try:
~/go/bin/dolt versionVerify that your installation has succeeded by running dolt in your
terminal.
$ dolt
Valid commands for dolt are
[...]Configure dolt with your user name and email, which you'll need to
create commits. The commands work exactly the same as git.
$ dolt config --global --add user.email [email protected]
$ dolt config --global --add user.name "YOUR NAME"Dolt needs a place to store your databases. I'm going to put my databases in ~/dolt.
% cd ~
% mkdir dolt
% cd doltAny databases you create will be stored in this directory. So, for this example, a directory named getting_started will be created here once you run create database getting_started. Navigating to ~/dolt/getting_started will allow you to access this database using the Dolt command line.
NOTE: For this example, the getting_started directory will be created after you run create database getting_started; in a SQL shell in the Create a schema section. Don't do anything except make the directory and navigate to it just yet.
Dolt ships with a MySQL compatible database server built in. To start it you use the command dolt sql-server. Running this command starts the server on port 3306.
dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"Your terminal will just hang there. This means the server is running. Any errors will be printed in this terminal. Just leave it there and open a new terminal.
In the new terminal, we will now connect to the running database server using a client. Dolt also ships with a MySQL compatible client.
% dolt -u root -p "" sql
# Welcome to the Dolt MySQL client.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
mysql>In the other terminal where you ran dolt sql-server, you'll see the following log line.
2022-06-06T13:14:32-07:00 INFO [conn 1] NewConnection {DisableClientMultiStatements=false}You are connected!
While we're here let's grab a copy of MySQL so we can connect with that client. Head over to the MySQL Getting Started documentation and install MySQL on your machine. I used Homebrew to install MySQL on my Mac: brew install [email protected]. Alternatively, you can install only the client component by running brew install [email protected].
NOTE: Make sure you install a MySQL 8.4 release. MySQL 8.4 is the current Long Term Support (LTS) release, meaning this is the stable and supported version of MySQL. MySQL 9.0 is also available, but is an "innovation" release, meaning it has more recent changes and features, but may not be as stable as the LTS release. The 9.0 release changes authentication support and isn't able to connect to a Dolt SQL server by default. You can install MySQL 8.4 with Homebrew by running brew install [email protected]. If you do want to use MySQL-9.0, read our post on how to configure Dolt for caching_sha2_password authentication.
MySQL comes with a MySQL server called mysqld and a MySQL client called mysql. You're only interested in the client. After following the instructions from MySQL's documentation, make sure you have a copy of the mysql client on your path:
% mysql --version
mysql Ver 8.0.29 for macos12.2 on x86_64 (Homebrew)Now, to connect the mysql client to Dolt, you are going to force the MySQL client through the TCP interface by passing in a host and port. The default is the socket interface which Dolt supports, but is only available on localhost. So, it's better to show off the TCP interface. The MySQL client also requires you specify a user, in this case root.
% mysql --host 127.0.0.1 --port 3306 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>Again, to ensure the client actually connected, you should see the following in the dolt sql-server terminal
2022-06-06T13:26:55-07:00 INFO [conn 2] NewConnection {DisableClientMultiStatements=false}As you can see, Dolt supports any MySQL-compatible client. Dolt ships with a client but you can use any MySQL client, like the one that comes with MySQL.
Now we're actually ready to do something interesting. I'll stay in the mysql client and execute the following SQL statements to create a database called getting_started. The getting_started database will have three tables: employees, teams, and employees_teams.
…Dolt supports foreign keys, secondary indexes, triggers, check constraints, and stored procedures. It's a modern, feature-rich SQL database.
It's time to use your first Dolt feature. We're going to make a Dolt commit. A Dolt commit allows you to time travel and see lineage. Make a Dolt commit whenever you want to restore or compare to this point in time.
Dolt exposes version control functionality through a Git-style interface. On the command line, Dolt commands map exactly to their Git equivalent with the targets being tables instead of files. In SQL, Dolt exposes version control read operations as system tables and version control write operations as stored procedures.
The naming of the system tables and stored procedures follows the dolt_<command> pattern. So dolt add on the CLI becomes dolt_add as a stored procedure. Passing options also follows the command line model. For instance, to specify tables to add, send the table names in as options to the dolt_add procedure. For named arguments like sending a message into the dolt_commit command use two arguments in sequence like ('-m', 'This is a message'). If you know Git, the version control procedures and system tables should feel familiar.
So, we add and commit our new schema like so.
…There you have it. Your schema is created and you have a Dolt commit tracking the creation, as seen in the dolt_log system table.
Note, a Dolt commit is different than a standard SQL transaction COMMIT. In this case, I am running the database with AUTOCOMMIT on, so each SQL statement is automatically generating a transaction COMMIT. If you want system to generate a Dolt commit for every transaction use the system variable, @@dolt_transaction_commit.
Now, I'm going to populate the database with a few employees here at DoltHub. Then, I'll assign the employees to two teams: engineering and sales. The CEO wears many hats at a start up so he'll be assigned to multiple teams.
…Oops, I violated a constraint. It looks like I created the table with teams before employees. You should always specify your columns when you insert, not rely on natural ordering. Serves me right! Dolt comes with the full power of a modern SQL relational data
git+https remote: Windows push fails on FETCH_HEAD 'Permission denied'; redundant fetch fan-out, no --no-write-fetch-head, console per git spawn
Update triggers do not fire on `INSERT INTO...ON DUPLICATE KEY UPDATE...`
UPDATE incorrectly permits a windowed target-table subquery
WHERE returns a row for an IN predicate that evaluates to FALSE
Support simple dynamic expressions on DOLT_DIFF
sql-server: provide a machine-readable startup-complete / readiness signal (--wait-for-ready / readiness file / sd_notify / documented log token)
Stored procedure that CALLs another procedure inside an explicit transaction silently discards the caller's earlier writes
Dolt returns no rows for EXCEPT-based intersection when the matching value is an empty string
git remote: since v2.1.2 a pull can re-download the whole database, because each process deletes its fetch ref
Dolt ignores default backslash escaping for wildcard characters in a window child