CSV Support for the Hosted Dolt Workbench

FEATURE RELEASEHOSTED
2 min read

Hosted DoltDB is for running online, production Dolt databases. Hosted comes with a built-in SQL Workbench. We recently added CSV support to the workbench, including uploading CSVs to update tables in your database and exporting query results as a CSV.

CSV Upload

Inspired by file upload on DoltHub, the Hosted workbench now supports CSV uploads to update tables in your database. You can choose to upload a file from your computer or use the spreadsheet editor to add rows to your table directly from the web interface.

Unlike DoltHub which uses the logic from dolt table import to perform the upload, file upload on Hosted is a wrapper on LOAD DATA. This results in some differences in the features for each product.

DoltHub vs Hosted File Upload

DoltHub Hosted
Wrapper on dolt table import Wrapper on LOAD DATA
Create, update, replace, or overwrite table Update table
Replace on duplicate key Choose to ignore or replace on duplicate key
Supports csv, psv, xlsx, json, or sql file types Supports csv and psv file types
Upload automatically creates commit and generates a pull request Upload updates working set without committing
File size up to 1GB File size up to 400MB*

* Subject to change

You'll also notice the same file upload on Hosted is faster than on DoltHub. The file upload process on DoltHub requires more steps and infrastructure than on Hosted, which you can learn more about here. On Hosted, files are simply passed over the wire to our GraphQL server (using graphql-upload), which connects to the Dolt SQL server and executes a LOAD DATA query.

How it works

This will take you through the steps of creating a new table and populating and updating it with a CSV through the file upload process.

1. Create a table

First create a new table called employees on a new branch called add-table, which was created from main. This is the schema:

CREATE TABLE `employees` (
  `id` int NOT NULL,
  `first_name` varchar(255),
  `last_name` varchar(255),
  `address` varchar(255),
  `city` varchar(100),
  `state` varchar(2),
  `country` varchar(100),
  `zip` varchar(5),
  `bio` varchar(1000),
  PRIMARY KEY (`id`)
);

You can execute the query directly from the workbench SQL console.

Create employees table

2. Edit the table

Click on the pencil icon next to the employees table in the left nav and choose "File Upload".

Edit employees table

3. Upload the file

Drag a file or browse files on your computer. Choose if you'd like to ignore or replace rows with a duplicate key. Click the "Upload" button.

Upload file

4. View table

You can now view your table and run queries against it.

View employees table

5. Create commit

If you are satisfied with your changes you can create a commit using the button above the table. This will execute the dolt_commit procedure using the message you provide.

Create commit

6. Update table

Make some updates to your original CSV and upload it to the employees table. Choose REPLACE.

Upload updated

Once the upload is complete, click on "Uncommitted changes" to view the diff of the new changes.

New changes diff

Export query results

You can now also export your query results as a CSV. Run a query and select "Download query results as CSV" from the Options dropdown above the table.

Download query results

You can change the file name and choose if you need to export the CSV for Excel (which will download the CSV with BOM so that you can open the file in Excel).

Download query results popup

Click on one of the export buttons and you've got your query results CSV!

Conclusion

CSV uploads and downloads are the latest workbench feature to make it easier for anyone, including Git or SQL beginners, to contribute to your Hosted Dolt database.

If you have any feedback on the Hosted workbench or want to use Hosted Dolt for your database, make a feature request on GitHub or reach out to us on Discord.

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.