Loading Data and Models
After configuring the project settings and exploring the information associated with it, you need to populate your database with data and models. This guide shows you how to load CSV data, load JSON data, sync your models with the cloud, and specify a task workflow.
Loading CSV Data
To load a CSV file:
-
Either:
- Under Admin > Commands, click Load CSV.
OR
- Type
RelationalAI: Load CSV
into the Command Palette.
-
Give your relation a name and click Enter (PC) or Return (Mac). This opens a file dialog.
-
Select the CSV file you want to load and click Open.
A message appears at the bottom to confirm that the data have been loaded. For an alternative approach, see Adding Base Relations in the Managing Relations guide.
This feature only works for CSV files up to 64MB in size.
Loading JSON Data
To load a JSON file :
-
Either:
- Under Admin > Commands, click Load JSON.
OR
- Type
RelationalAI: Load JSON
into the Command Palette.
-
Give your relation a name and click Enter (PC) or Return (Mac). This opens a file dialog.
-
Select the JSON file you want to load and click Open.
A message appears at the bottom to confirm that the data have been loaded. For an alternative approach, see Adding Base Relations in the Managing Relations guide.
Syncing Models
To keep your local collection of models in your .rel
files in sync with the models stored in the database in the cloud, either:
- Under Admin > Commands, click Sync Models with Cloud.
OR
- Type RelationalAI: Sync Models With Cloud into the Command Palette.
This adds the models in the cloud to your local project directory and vice versa. If there are conflicts, you will get a notification asking how you want to resolve them.
Specifying Task Workflow
You can specify sequences of operations to be performed in a task file, to be stored in a directory called task
.
Here’s an example task file (task/example.toml
):
[[step]]
name = "load helper relations"
mode = "model"
file_path = "model/helper"
[[step]]
name = "load data"
mode = "write"
file_path = "write/load-data.rel"
inputs = [
{ csv_data = "data/my-data.csv" }
]
[[step]]
name = "load remaining models"
mode = "model"
file_paths = [
"model/business-logic.rel",
"model/display-features.rel"
]
This example assumes that:
load-data.rel
contains code like this:
def config:data = csv_data
def insert:my_relation = load_csv[config]
-
data/my-data.csv
is a valid CSV file containing the desired data. -
model/helper
is a directory containing.rel
files.
Each step should include a name, a mode (which can be read
, write
, or model
), either file_path
or file_paths
, and optionally inputs
.
The file_path
or file_paths
field should be a path or paths, respectively, to files relative to the root of the project directory.
Alternatively, any entry may be a directory, in which case it will be expanded to all of the .rel
files contained in that directory (recursively).
The inputs
field should be a list of objects, each of which should have a single key-value pair.
The key should be the name of a variable to be referred to in the Rel file or files, and the value should be the path to a file whose contents will be inserted for that variable in the Rel files.
You can create a new task or a new step in a task using the commands "RelationalAI: New Task"
and "RelationalAI: New Task Step"
.
It will walk you through a series of prompts and insert a TOML entry that corresponds to the options you select.
Running a Task
To run a task:
-
Either:
- Under Admin > Commands, click Run Task.
OR
- In the Command Palette, type
RelationalAI: Run Task
.
-
Select a task file.
The task will be run in the background, and you can view its progress in the Status Bar along the bottom of the window.