fbpx
By using our website, you agree to the use of our cookies.

Blog Post

Dolt is Git for Data: a SQL database that you just’d fork, clone, branch, merge
MooMoon My ID 822-dolt-is-git-for-data-a-sql-database-that-you-justd-fork-clone-branch-merge
Tech News

Dolt is Git for Data: a SQL database that you just’d fork, clone, branch, merge 

Dolt is Git for Data!

Dolt is a SQL database that you just’d fork, clone, branch, merge, push
and pull accurate indulge in a git repository. Hook up with Dolt accurate indulge in each and each
MySQL database to lumber queries or replace the knowledge utilizing SQL
commands. Advise the uncover line interface to import CSV recordsdata, commit
your changes, push them to a a ways-off, or merge your teammate’s changes.

Your whole commands you perceive for Git work precisely the same for Dolt. Git
variations recordsdata, Dolt variations tables. It be indulge in Git and MySQL had a
child!

We additionally built DoltHub, a collection to half
Dolt databases. We host public knowledge with out cost!

Be half of us on Discord to command hi there and
seek recordsdata from questions!

What’s it for?

Hundreds things! Dolt is a on the whole invaluable scheme with limitless
capabilities. Nonetheless in relate for you some tips, here is how other folks are utilizing
it to this level
.

$ dolt
Profitable commands for dolt are
                init - Attach an empty Dolt knowledge repository.
              feature - Demonstrate the working tree feature.
                 add - Add desk changes to the list of staged desk changes.
               reset - Choose away desk changes from the list of staged desk changes.
              commit - File changes to the repository.
                 sql - Speed a SQL seek recordsdata from in opposition to tables in repository.
          sql-server - Initiate a MySQL-correctly marvelous server.
                 log - Demonstrate commit logs.
                diff - Diff a desk.
               blame - Demonstrate what revision and creator closing modified each and each row of a desk.
               merge - Merge a branch.
              branch - Attach, list, edit, delete branches.
                 imprint - Attach, list, delete tags.
            checkout - Checkout a branch or overwrite a desk from HEAD.
              a ways-off - Arrange roar of tracked repositories.
                push - Push to a dolt a ways-off.
                pull - Receive from a dolt a ways-off knowledge repository and merge.
               acquire - Update the database from a a ways-off knowledge repository.
               clone - Clone from a a ways-off knowledge repository.
               creds - Commands for managing credentials.
               login - Login to a dolt a ways-off host.
             model - Displays the recent Dolt cli model.
              config - Dolt configuration.
                  ls - Record tables within the working roar.
              schema - Commands for showing and importing desk schemas.
               desk - Commands for copying, renaming, deleting, and exporting tables.
           conflicts - Commands for viewing and resolving merge conflicts.
             migrate - Executes a repository migration to interchange to primarily the most traditional layout.
         read-tables - Receive desk(s) at a explicit commit into a brand original dolt repo
                  gc - Cleans up unreferenced knowledge from the repository.

From Most traditional Free up

To put in on Linux or Mac based mostly systems lumber this uncover on your
terminal:

sudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/most traditional/salvage/install.sh | bash'

It can perchance salvage primarily the most traditional dolt release and set it in
/usr/local/bin/, which is perchance on your $PATH.

Homebrew

Dolt is on Homebrew, up up to now each and each release.

brew install dolt

Windows

Download primarily the most traditional Microsoft Installer (.msi file) in
releases and lumber
it. Equipment manager releases coming soon!

For knowledge on working on Windows, learn here.

From Source

Be particular you hold Go installed, and that disappear is on your course.

Clone this repository and cd into the disappear directory. Then lumber:

disappear install ./cmd/dolt

Take a look at that your installation has succeeded by working dolt on your
terminal.

$ dolt
Profitable commands for dolt are
[...]

Configure dolt with your individual title and e mail, which it is possible you’ll perchance must
get commits. The commands work precisely equivalent to git.

$ dolt config --global --add individual.e mail YOU@DOMAIN.COM
$ dolt config --global --add individual.title "YOUR NAME"

Let’s get our first repo, storing roar inhabitants knowledge.

$ mkdir roar-pops
$ cd roar-pops

Speed dolt init to roar up a brand original dolt repo, accurate indulge in you get with
git. Then lumber some SQL queries to insert knowledge.

$ dolt init
Successfully initialized dolt knowledge repository.
$ dolt sql -q "get desk state_populations ( roar varchar(14), inhabitants int, predominant key (roar) )"
$ dolt sql -q "indicate tables"
+-------------------+
| tables            |
+-------------------+
| state_populations |
+-------------------+
$ dolt sql -q "insert into state_populations (roar, inhabitants) values
('Delaware', 59096),
('Maryland', 319728),
('Tennessee', 35691),
('Virginia', 691937),
('Connecticut', 237946),
('Massachusetts', 378787),
('South Carolina', 249073),
('Unusual Hampshire', 141885),
('Vermont', 85425),
('Georgia', 82548),
('Pennsylvania', 434373),
('Kentucky', 73677),
('Unusual York', 340120),
('Unusual Jersey', 184139),
('North Carolina', 393751),
('Maine', 96540),
('Rhode Island', 68825)"
Request OK, 17 rows affected

Advise dolt sql to leap into a SQL shell, or lumber single queries with
the -q possibility.

$ dolt sql -q "seize out from state_populations the set roar='Unusual York'"
+----------+------------+
| roar    | inhabitants |
+----------+------------+
| Unusual York | 340120     |
+----------+------------+

add the original tables and commit them. Every uncover suits git
exactly, however with tables as a replace of recordsdata.

$ dolt add .
$ dolt commit -m "preliminary knowledge"
$ dolt feature
On branch master
nothing to commit, working tree correctly-organized

Update the tables with more SQL commands, this time utilizing the shell:

$ dolt sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
state_pops> replace state_populations roar inhabitants=0 the set roar indulge in 'Unusual%';
Request OK, 3 rows affected
Rows matched: 3  Modified: 3  Warnings: 0
state_pops> exit
Bye

Gaze what you changed with dolt diff:

$ dolt diff
diff --dolt a/state_populations b/state_populations
--- a/state_populations @ qqr3vd0ea6264oddfk4nmte66cajlhfl
+++ b/state_populations @ 17cinjh5jpimilefd57b4ifeetjcbvn2
+-----+---------------+------------+
|     | roar         | inhabitants |
+-----+---------------+------------+
|    | Unusual Hampshire | 0          |
|    | Unusual Jersey    | 0          |
|    | Unusual York      | 0          |
+-----+---------------+------------+

Then commit your changes all any other time with dolt add and dolt commit.

$ dolt add state_populations
$ dolt commit -m "More indulge in Gentle Jersey"

Gaze the ancient previous of your repository with dolt log.

% dolt log
commit babgn65p1r5n36ao4gfdj99811qauo8j
Creator: Zach Musgrave 
Date:   Wed Nov 11 13: 42: 27 -0800 2020

    More indulge in Gentle Jersey

commit 9hgk7jb7hlkvvkbornpldcopqh2gn6jo
Creator: Zach Musgrave 
Date:   Wed Nov 11 13: 40: 53 -0800 2020

    preliminary knowledge

commit 8o8ldh58pjovn8uvqvdq2olf7dm63dj9
Creator: Zach Musgrave 
Date:   Wed Nov 11 13: 36: 24 -0800 2020

    Initialize knowledge repository

In the occasion you hold knowledge in flat recordsdata indulge in CSV or JSON, you’d import them
utilizing the dolt desk import uncover. Advise dolt desk import -u to
add knowledge to an existing desk, or dolt desk import -c to get a
original one.

$ head -n3 knowledge.csv
roar,inhabitants
Delaware,59096
Maryland,319728
$ dolt desk import -c -pk=roar state_populations knowledge.csv

Genuine indulge in with git, or now now not it is miles a accurate suggestion to fabricate changes on your absorb
branch, then merge them abet to master. The dolt checkout uncover
works precisely equivalent to git checkout.

$ dolt checkout -b 

The merge uncover works the same too.

$ dolt merge 

Dolt supports remotes accurate indulge in git. Remotes are roar up robotically
must you clone knowledge from one.

$ dolt clone dolthub/corona-virus
...
$ cd corona-virus
$ dolt a ways-off -v
starting up https://doltremoteapi.dolthub.com/dolthub/corona-virus

To push to a a ways-off, it is possible you’ll perchance need credentials. Speed dolt login to originate
a browser to signal in and cache your local credentials. You’d signal
into DoltHub with your Google chronicle, your Github chronicle, or with a
individual title and password.

$ dolt login

In the occasion you hold a repo that you just created regionally that you just now are desirous to push
to a a ways-off, add a a ways-off exactly indulge in you’d with git.

$ dolt a ways-off add starting up myname/myRepo
$ dolt a ways-off -v
starting up https://doltremoteapi.dolthub.com/myname/myRepo

After which push to it.

$ dolt push starting up master

Assorted remotes

dolt additionally supports directory, aws, and gcs based mostly remotes:

  • file – Advise a directory on your machine
dolt a ways-off add  file:///Users/xyz/abs/course/
  • aws – Advise an S3 bucket
dolt a ways-off add  aws://dynamo-desk:s3-bucket/database
  • gs – Advise a GCS bucket
dolt a ways-off add  gs://gcs-bucket/database

DoltHub has a whole bunch interesting datasets to
explore and clone. Listed below are just a few of our favorites.

There’s plenty more to Dolt than can fit in a README file! For beefy
documentation, compare out the docs on
DoltHub
. About a of the topics we didn’t
conceal here:

Dolt depends closely on originate source code and tips from the
Noms project. We are very
thankful to the Noms team for making this code freely available,
with out which we don’t had been ready to fabricate Dolt so .

Dolt is licensed under the Apache License, Model 2.0. Gaze
LICENSE for
little print.

Read More

Related posts

en English
X