'DoltHub' that can manage database version and host like GitHub
The source code version control system '
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.
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.
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
('South Carolina', 249073),
('New Hampshire', 141885),
('New York', 340120),
('New Jersey', 184139),
('North Carolina', 393751),
('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...
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.