From Your Local Machine
Single file
- CLI
- UI
Using the CLI, you can connect to MotherDuck, create a database, and load a single local file (JSON, Parquet, CSV, etc.) to a MotherDuck table.
First, connect to MotherDuck using the ATTACH
command.
ATTACH 'md:';
Create a cloud database (or point to any existing one) and load a local file into a table.
CREATE DATABASE test01;
USE test01;
CREATE OR REPLACE TABLE orders as SELECT * from 'orders.csv';
In the MotherDuck UI, you can add JSON, CSV or Parquet file directly using the Add Files button in the top left of the UI. See the Getting Started Tutorial for details.
Multiple files or database
To upload multiple files at once, or data in other formats supported by DuckDB, you can use the DuckDB CLI or any other supported DuckDB client.
- CLI
If your all your files reside from a single table, you can use the glob syntax to load all files into a single table.
For example, to load all CSV files from a directory into a single table, you can use the following SQL command:
ATTACH 'md:';
CREATE DATABASE test01;
USE test01;
CREATE OR REPLACE TABLE orders as SELECT * from 'dir/*.csv';
If your files are in different formats or you want to load them into different tables, you can first load the files into different tables in a local DuckDB database and then copy the entire database into MotherDuck.
To copy the entire local DuckDB database into MotherDuck, you can use the following SQL commands:
ATTACH 'md:';
ATTACH 'local.ddb';
CREATE DATABASE cloud_db from 'local.ddb';