diff --git a/docs/src/content/docs/getting-started/first-ui-app.mdx b/docs/src/content/docs/getting-started/first-ui-app.mdx index 4d807d9..6ea2a13 100644 --- a/docs/src/content/docs/getting-started/first-ui-app.mdx +++ b/docs/src/content/docs/getting-started/first-ui-app.mdx @@ -39,39 +39,14 @@ We'll use the `sqlite3` CLI[^1] directly to import `examples/coffeesearch/arabica_data_cleaned.csv` with the following SQL script: -```sql --- First create the strictly typed "coffee" table. -CREATE TABLE IF NOT EXISTS coffee ( - Species TEXT, - Owner TEXT, - - Aroma REAL, - Flavor REAL, - Acidity REAL, - Sweetness REAL, - - embedding BLOB -) STRICT; - --- Then import the data into a "temporary" table. -.mode csv -.import arabica_data_cleaned.csv temporary - --- Then import the temporary data into the "coffee" table. -INSERT INTO coffee (Species, Owner, Aroma, Flavor, Acidity, Sweetness) -SELECT - Species, - Owner, - - CAST(Aroma AS REAL) AS Aroma, - CAST(Flavor AS REAL) AS Flavor, - CAST(Acidity AS REAL) AS Acidity, - CAST(Sweetness AS REAL) AS Sweetness -FROM temporary; - --- And clean up. -DROP TABLE temporary; -``` +import importScript from "../../../../../examples/coffeesearch/import.sql?raw"; + + Note that we didn't initialize the vector `embedding`. This is merely because `sqlite3` doesn't have the necessary extensions built-in. @@ -82,6 +57,7 @@ From within the `example/coffeesearch` directory, you can execute the script above and import the coffee data by running: ```bash +$ mkdir -p traildepot/data $ cat import.sql | sqlite3 traildepot/data/main.db - ``` diff --git a/examples/coffeesearch/import.sql b/examples/coffeesearch/import.sql index 53057e3..2107c2a 100644 --- a/examples/coffeesearch/import.sql +++ b/examples/coffeesearch/import.sql @@ -1,5 +1,5 @@ --- Create table if it doesn't exist. -CREATE TABLE IF NOT EXISTS coffee ( +-- First create the strictly typed "coffee" table. +CREATE TABLE coffee ( Species TEXT, Owner TEXT, @@ -11,22 +11,21 @@ CREATE TABLE IF NOT EXISTS coffee ( embedding BLOB ) STRICT; --- Go on to import data. -DROP TABLE IF EXISTS temporary; - +-- Then import the data into a "temporary" table. .mode csv .import arabica_data_cleaned.csv temporary +-- Then import the un-typed temporary data into the typed "coffee" table. INSERT INTO coffee (Species, Owner, Aroma, Flavor, Acidity, Sweetness) -SELECT - Species, - Owner, + SELECT + Species, + Owner, - CAST(Aroma AS REAL) AS Aroma, - CAST(Flavor AS REAL) AS Flavor, - CAST(Acidity AS REAL) AS Acidity, - CAST(Sweetness AS REAL) AS Sweetness -FROM temporary; + CAST(Aroma AS REAL) AS Aroma, + CAST(Flavor AS REAL) AS Flavor, + CAST(Acidity AS REAL) AS Acidity, + CAST(Sweetness AS REAL) AS Sweetness + FROM temporary; --- Clean up. +-- And clean up. DROP TABLE temporary;