11  Exporting Data

The Research Information Gateway offers two primary methods to export data from Dolt:

  1. SQL Dump: Generate a complete database dump in SQL format for importing into other database systems like MySQL. This approach exports the entire database with schema and data.

  2. CSV Export via DoltHub API: Extract specific tables or query results as CSV files through the DoltHub API. This method is useful for targeted exports or when you need data in a format compatible with spreadsheet applications.

11.1 Exporting Data to a MySQL Database

  1. Open the terminal or command prompt.

  2. Navigate to the Dolt database directory.

  3. Run the following command to create a SQL dump file:

    dolt dump -f
  4. This will create a file called doltdump.sql that contains all the SQL statements needed to recreate the database structure and data.

11.1.1 Notes

The doltdump.sql is currently ~ 235Mb in size.

11.2 Importing Data into MySQL

  1. Make sure MySQL is installed and running.

  2. Import the dump file into the MySQL database:

    mysql -u username -p database_name < doltdump.sql

    Replace username with the appropriate MySQL username and database_name with the name of the target MySQL database.

  3. When prompted, enter the MySQL password.

  4. Wait for the import process to complete.

11.2.1 Notes

  • The generated SQL dump contains standard SQL that’s compatible with MySQL.
  • This approach migrates both the schema (tables, views, etc.) and data in one operation.
  • You may need to create the target MySQL database first if it doesn’t already exist.