## Dolt Dolt is Git for data! Dolt is a relational database, i.e. it has tables, and you can execute SQL queries against those tables. It also has version control primitives that operate at the level of table cell. Thus Dolt is a database that supports fine grained value-wise version control, where all changes to data and schema are stored in commit log. It is inspired by RDBMS and Git, and attempts to blend concepts about both in a manner that allows users to better manage, distribute, and collaborate on, data. We also built [DoltHub](https://www.dolthub.com), a cloud based storage solution for hosting Dolt databases, that facilitates collaborative management of databases. We host public data for free! If you want to discuss Dolt, feel free to join our [Discord](https://discord.com/invite/RFwfYpu). We are happy to discuss use-cases, the roadmap, or anything related to version controlled databases. ## Dolt CLI ``` $ dolt Valid commands for dolt are init - Create an empty Dolt data repository. status - Show the working tree status. add - Add table changes to the list of staged table changes. reset - Remove table changes from the list of staged table changes. commit - Record changes to the repository. sql - Run a SQL query against tables in repository. sql-server - Starts a MySQL-compatible server. log - Show commit logs. diff - Diff a table. blame - Show what revision and author last modified each row of a table. merge - Merge a branch. branch - Create, list, edit, delete branches. checkout - Checkout a branch or overwrite a table from HEAD. remote - Manage set of tracked repositories. push - Push to a dolt remote. pull - Fetch from a dolt remote data repository and merge. fetch - Update the database from a remote data repository. clone - Clone from a remote data repository. creds - Commands for managing credentials. login - Login to a dolt remote host. version - Displays the current Dolt cli version. config - Dolt configuration. ls - List tables in the working set. schema - Commands for showing and importing table schemas. table - Commands for copying, renaming, deleting, and exporting tables. conflicts - Commands for viewing and resolving merge conflicts. ``` ## Installation These installation instructions assume that you have Go installed, and that `go` is in your path. ### From Latest Release To install on Linux or Mac based systems run: ```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```. For Windows, locate the latest Microsoft Installer (`.msi` file) in [releases](https://github.com/dolthub/dolt/releases), and run it. This will install the latest dolt. ### From Source Alternatively clone this repository and then, assuming you cloned the repository into your home directory: ``` $ cd ~/dolt/go $ go install ./cmd/dolt [...] $ go install ./cmd/git-dolt [...] $ go install ./cmd/git-dolt-smudge [...] ``` This will install the requisite binaries at `$GOPATH/bin`, which defaults to `$HOME/go`, thus you should see something like (unless you set `$GOPATH` to something else): ``` $ ls -ltr $HOME/go/bin/ dolt git-dolt git-dolt-smudge ``` Ensure that `$GOPATH/bin` is on your path, and then proceed. ### Verify Whichever method you used, verify that your installation has succeeded as follows: ``` $ dolt Valid commands for dolt are [...] ``` Finally, setup your name and email in the global config (this should be very familiar to Git users): ``` $ dolt config --global --add user.email YOU@DOMAIN.COM $ dolt config --global --add user.name "YOUR NAME" ``` You're all set to start getting value from Dolt! ## First Repository Suppose we want to create a table of state populations from 1790 in Dolt, then: ``` $ mkdir state-populations $ cd state-populations ``` Initialize the directory, and load some data: ``` $ dolt init Successfully initialized dolt data repository. $ dolt sql -q "create table state_populations ( state varchar(14), population int, primary key (state) )" $ dolt sql -q "show tables" +-------------------+ | tables | +-------------------+ | state_populations | +-------------------+ $ dolt sql -q 'insert into state_populations (state, population) values ("Delaware", 59096), ("Maryland", 319728), ("Tennessee", 35691), ("Virginia", 691937), ("Connecticut", 237946), ("Massachusetts", 378787), ("South Carolina", 249073), ("New Hampshire", 141885), ("Vermont", 85425), ("Georgia", 82548), ("Pennsylvania", 434373), ("Kentucky", 73677), ("New York", 340120), ("New Jersey", 184139), ("North Carolina", 393751), ("Maine", 96540), ("Rhode Island", 68825)' Rows inserted: 17 ``` Now let's run some SQL against it: ``` $ dolt sql -q "select * from state_populations where state = 'New York'" +----------+------------+ | state | population | +----------+------------+ | New York | 340120 | +----------+------------+ ``` Assuming you're satisfied, create a commit as follows: ``` $ dolt add . $ dolt commit -m "Add state populations from 1790" $ dolt status On branch master nothing to commit, working tree clean ``` You've just generated your first commit to a relational database with version control! Alternatively, you can import CSV and PSV files, where the file type is inferred from the extension. Suppose your state populations are in a file: ``` $ head -n3 data.csv state,population Delaware,59096 Maryland,319728 $ dolt table import -pk=state state_populations data.csv ``` Note if you do not have a file extension, i.e. your file is called `data`, Dolt will think you are trying to import from another table and thus not behave in the way you expect. ## Modifying Data Override the table with the contents of another file: ``` $ dolt table import --update-table