Dolt — Using SQL Database like Git

For today I review about fundamental of Git again because I forgot some content like Merge vs Rebase, Git workflow, Worktree, etc. Suddenly I found keyword Git for Data, so I’d know what is difference with Git, so I learn and write in this blog.

What is Dolt?

Dolt is opensource SQL database. You can run base command like Git for manage your data, create new branch, checkout to it, insert new data, commit them, get log information, and diff changed data. They have private and public repository on Dolthub.

In my opinion, it’s so familiar with Git, but doesn’t exactly the same, because it focus on the data. It’s work well with Public Data Source.

Use Case

  • For QA / tester, initial data set for test with SQL database in each branch such as data-set-for-integration-test, data-set-for-end-to-end-test. Switch branch into it when you need to test in difference data set.
  • For infrastrucutre, snapshot data with specific table. Export and import them when need, and track changed data by log time, commit hash.
  • For your teammate, you can share the data in your local machine with your team. Pull it in their machine, and merge your data with their data.
Dolt Command in CLI
When run command: dolt log

My Example

Create new database and table.

  • Database name: dolt_example
  • Table name: User (ID int)
Dolt Schema Show

Create new branch name

  • master
  • add-new-user
Dolt Example Branch

Insert new data into user table that data come from difference branch and merge them into master branch.

Dolt SQL SELECT from user table

Insert new data (id = {6, 7, 8}) into user table and try to run data diff. You can run checkout for discard changes data if need.

Dolt get status in master branch and diff user table

Run snapshot data into dolt database with mysql compatible server. the database can CRUD from other process.

Dolt run mysql compatible server

Insert data (id = 9) from other process via mysql compatible server, and data change immediately.

Dolt diff after insert data from other process

Commit new data change for backup into data revision

Export to sql command file for make sure data that should be backup

Dolt export table user into sql command file

Import data from SQL command file. They force to do with dolt sql command

So I read file and send into stdin with pipe

Dolt import table

Remove table user and import from sql command and checkout from revision HEAD for move to before remove table

Dolt remove table and checkout to revision HEAD


Fail Fast, Succeed Faster 🚀

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store