'DoltHub' that can manage database version and host like GitHub

The source code version control system '

Git ' and the source code hosting ' GitHub ' are now indispensable in software development. It is ' DoltHub ' and ' Dolt ' that can manage the database like managing the source code with Git and GitHub.


GitHub-liquidata-inc/dolt: Dolt – It's Git for Data

First, to create a DoltHub account, access the top page and click 'Sign In'.

Click Sign up for Dolt Hub.

At the time of article creation, Google account and GitHub account can be used for account creation. This time I will use a Google account.

If you are logged in with a Google account, the account selection screen will be displayed. Select the account you want to use for account registration.

A screen for entering the user name you want to use on DoltHub is displayed, so enter the user name and click 'Submit'.

The DoltHub home screen is displayed. DoltHub is now ready for use.

Then install Dolt in your development environment. You can copy the command to install Dolt by returning to the top page of DoltHub and clicking the button in the red frame.

Execute the copied command in the development environment. This time, Ubuntu 20.04 is used as the development environment. The script is downloaded and executed, and the binary file is placed under '/usr/local/bin'.

The options for the Dolt command look like this. You can use familiar options in Git such as 'commit', 'merge' and 'push'.

First of all, set the email address and user name used for Dolt. It can be configured like Git.

Execute the following command to connect to DoltHub.

[code]dolt login[/code]

When you execute the command, the URL for authentication is displayed. Access it with a browser.

When accessing the URL with a browser, a screen for adding authentication was displayed. Click 'Create' after entering the authentication description.

Then, a message indicating that the authentication was successful was displayed on the command line screen. You can now access DoltHub from Dolt installed in your development environment.

Next, create a repository on DoltHub. From 'Create New Repository', enter the owner and repository name and click 'Create repository'. In the free version, only public repositories can be created.

A command to set up a remote repository with Dolt was displayed.

You can configure the remote repository by executing the displayed command from the command line.

Now that the development environment is all in place, it's time to create the database. Dolt's GitHub page showed how to create a database of 'populations by state in the United States', so let's create it as an example.

First, execute the following command in the project directory to create a table. Describe the SQL statement after the '-q' option to operate the database.

[code]dolt sql -q 'create table state_populations (state varchar(14), population int, primary key (state) )'[/code]

Then check if the table was created with the following command.

[code]dolt sql -q 'show tables'[/code]

It was confirmed that a table named 'state_population' was created.

We will add records to the table.

[code]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)'[/code]

If you display the row where the 'state' column is 'New York' with the following command...

[code]dolt sql -q 'select * from state_populations where state ='New York''[/code]

The state name and population were displayed properly.

At this point add the database to the master branch.

[code]dolt add .[/code]

When you check the status, a message saying 'New table has been added, please commit' is displayed.

Then push commit on the master branch to the remote repository...

[code]dolt push origin master[/code]

You can now see your database on the DoltHub page.

I want to add a new state called 'My State', so add it with the following command.

[code]dolt sql -q'INSERT INTO state_populations VALUES ('My State', 30000)'[/code]

Check the database changes with the following command...

[code]dolt diff[/code]

The added record is displayed properly.

Reflect changes to remote repository.

When checked on DoltHub, the added My State record was reflected.

Check the Commit Log on the left.

It is possible to check the difference by comparing each commit like this. DoltHub has other functions such as Pull Request, so you can manage the database as you manage the source code.

in Review,   Software,   Web Service, Posted by darkhorse_log