Dolt now supports dump

FEATURE RELEASESQL
3 min read

Dolt is a database with Git-style version control features. In order to provide features like diff and merge at database scale, we wrote a whole new database storage engine. This means in order to use Dolt you have to import your data into it. Dolt does not just run on top of your existing database, it replaces your existing database. We spent a lot of time getting all manner of imports to work in Dolt. It's only recently that people have started to ask for ways to get their data out of Dolt.

To that end, today, we announce support for dolt dump. Dolt dump allows you to dump the contents of your database, schema and data, to a file like mysqldump or pg_dump. Dolt dump supports sql, csv, json and parquet file types.

It's based on mysqldump and pg_dump

The Dolt dump command has the basic core functionality of mysqldump and pg_dump commands. Using mysqqldump and pg_dump as baseline makes it easier to understand and more comfortable to use for database developers. For people familiar mysqldump or pg_dump, the Dolt dump command will export all tables in a working set to a file that you can specify with -r flag. Dolt dump defaults to sql file type, which will create a single sql file. The dump file produced is MySQL compatible, so you can import your dumped data into any MySQL database.

Genius request

Before Dolt dump, there was no way to export your data all at once. You had to export all tables one by one, which can be dreadful process to go through depending on the number of tables you have in your database. If you have 100 tables you want to export, imagine running the export command 100 times. I might be overexaggerating the process, who knows it might be not so bad, but I bet no one would enjoy that. One of the people who did not enjoy doing this requested dolt dump. What an awesome idea that would save people's lives! Just kidding, but it would certainly save many people's precious time.

First let's go over examples for dolt dump usage. I used the current bounty database, SHAQ, that you can make money from. I made the examples more detailed for someone like myself, who did not have previous knowledge about using mysqldump or pg_dump commands.

$ dolt clone dolthub/SHAQ
cloning https://doltremoteapi.dolthub.com/dolthub/SHAQ
110,986 of 110,986 chunks complete. 0 chunks being downloaded currently.
$ cd SHAQ
SHAQ $ dolt ls
Tables in working set:
	 league_seasons
	 leagues
	 player_season_stat_totals
	 players
	 season_types
	 team_seasons
	 teams
  1. dolt dump command defaults to result format of .sql and dumps all the tables to default filename of

doltdump.sql file within the same directory.

SHAQ $ dolt dump
Successfully exported data.

SHAQ $ ls
README.md	doltdump.sql
  1. You can specify the file type you want to store your data as, and it will use table name as filename.
SHAQ $ dolt dump -r csv
Successfully exported data.

SHAQ $ cd doltdump && ls
league_seasons.csv		season_types.csv
leagues.csv			team_seasons.csv
player_season_stat_totals.csv	teams.csv
players.csv
  1. Filename for .sql and directory name for .csv, .json, .parquet as well as the filename for sql file or directory name for csv, json and parquet file types.
SHAQ $ dolt dump -r sql --file-name shaq_database.sql
Successfully exported data.

SHAQ $ ls
README.md	shaq_database.sql

My first feature in Dolt!

So, this issue filed on Github became my first feature I developed in Dolt, which was super exciting to me. Not only did it feel challenging, but this was also my first time programming in Golang. As many of you can relate to as a new graduate getting their first work project either recently or sometime in the past, you probably know the excitement before, stress and enjoyment during and happiness also during but mostly after the project.

What's missing?

Dolt dump command takes care of the basic need of dumping all tables in your working set; however, it is missing some things.

The first is handling foreign keys. Since tables in the working set are ordered lexically by their names, dumping tables with foreign keys gets tricky. A foreign key in one table represents a primary key in another, so for example, if the table with foreign keys is stored before another table with its primary key linked to it in the same file, importing that data back to your database would need additional support to be able to restore your data.

The second is dumping views or triggers. The current version of dolt dump exports tables that are only in a working set of the database. In Dolt, views and triggers are stored in special dolt_schemas system table, which is not a part of the working set of the database.

Give Dolt a try!

If you want to learn more cool things about Dolt, check out our documentation page. If you have questions, comments or suggestions, our team is one-click away on Discord.

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.