Skip to content

Commit

Permalink
docs: describe the init_sqlite function
Browse files Browse the repository at this point in the history
  • Loading branch information
frectonz committed Nov 20, 2024
1 parent 0b51627 commit 0e1b2ba
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ CREATE EXTENSION pglite_fusion;
-- Create a table with an SQLite column
CREATE TABLE people (
name TEXT NOT NULL,
database SQLITE DEFAULT execute_sqlite(
empty_sqlite(),
'CREATE TABLE todos (task TEXT)'
)
database SQLITE DEFAULT init_sqlite('CREATE TABLE todos (task TEXT)')
);

-- Insert a row into the people table
Expand Down Expand Up @@ -132,6 +129,26 @@ WHERE name = 'frectonz';

-----

### `init_sqlite`

Creates an SQLite database with an initialization query already applied on it. This can be used to initialize a SQLite database with the expected tables already created.

#### Parameters:

- `query`: The SQL statement to execute on the SQLite database.

##### Example Usage:

```sql

CREATE TABLE people (
name TEXT NOT NULL,
database SQLITE DEFAULT init_sqlite('CREATE TABLE todos (task TEXT)')
);
```

-----

### `get_sqlite_text`
Extracts a text value from a specific column in a row returned by `query_sqlite`. Use this function to retrieve text values from query results.

Expand Down

0 comments on commit 0e1b2ba

Please sign in to comment.