Data Sharing
Last updated
Last updated
Our discover page on DoltHub lets you find public databases created by users in our community. You can easily share these databases and adopt them for your own use cases.
See an interesting database you'd like to make changes to? Get the database locally with just one command (assuming you have Dolt installed), which is found on every database page:
We are going to use the dolthub/corona-virus
database as an example
Once you've cloned a database from DoltHub, you can use the SQL shell to make a change to the data. We're going to add a row to the cases
table on a new branch:
You can see how the insert query changed the cases
table by viewing the diff:
If the change looks good we add the table and commit:
Now that we've made a change locally using Dolt, we want to push the change back to DoltHub so that it can be incorporated into the database.
Since we don't have write permissions to dolthub/corona-virus
, we need to fork it to our own namespace. This is easily done using the fork button:
Now we have a database in our namespace that we can write to (taylor/corona-virus
).
Now that we have a fork of the original database, we need to add a remote to our locally cloned database.
We now have two remotes: origin
which refers to the dolthub/corona-virus
database on DoltHub, and taylor
which refers to the fork taylor/corona-virus
on DoltHub.
Before we can push changes to our remote, we need to log in to Dolt so that it can recognize DoltHub as the remote database. First, run the dolt login
command:
This will open your browser to the credentials settings page with the hash from above populated in the "Public key" field. Add a name for the token and click Create
:
You should see this message if it was successful:
You are now logged in and can push data to DoltHub.
We want to push the new branch we made changes to locally to the remote fork.
When you navigate to the fork on DoltHub, you'll see the new branch in the branch selector dropdown on the left:
In order to incorporate this change into the parent database (dolthub/corona-virus
), we need to create a pull request. A pull request is a way to propose changes to a database and discuss these changes with the database owners.
To create a pull request, we first navigate to the parent database. In the "Pull Requests" tab click on the "Create Pull Request" button. Choose your fork as the "From database" and add a title and description.
The database owner can now view your changes and request updates if needed. You can make changes to your pull request by creating a new commit with a change on the same branch and pushing again. Once the owner is satisfied with the change they can decide to merge the pull request, which would update the parent database's main branch.