You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sqlite-cloud/create-database.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,17 +31,19 @@ To upload a local SQLite database via the SQLite Cloud UI, navigate to the Datab
31
31
### Via Dashboard UI
32
32
To import a database from the UI, navigate to the Databases tab and click the "Upload Database" button.
33
33
34
+
Select the database file you want to upload, and click "Upload Database". The database will be available in your cluster within a few minutes.
35
+
34
36
<VideoPlayersrc={uploadDb} />
35
37
36
-
Select the database file you want to upload, and click "Upload Database". The database will be available in your cluster within a few minutes.
37
38
38
39
## Creating a new database
39
40
### From the Dashboard
40
41
41
42
To create a new database from the SQLite Cloud UI, navigate to the Databases tab and click the "Create Database" button.
42
-
<VideoPlayersrc={createDb} />
43
43
44
44
The default encoding is set to UTF-8, and the default page size is 4096KB.
45
+
<VideoPlayersrc={createDb} />
46
+
45
47
46
48
### From the API
47
49
To create a new database or upload an existing database via [Weblite](/docs/weblite), our REST API, you can make a request with the following parameters:
The Analyzer panel is a powerful tool that collects and categorizes all the queries executed on your cluster based on their execution time. It allows for intelligent and proactive analysis, and provides recommendations on which indexes to use to optimize frequently used queries.
By default, the Analyzer is turned off to avoid a small performance penalty. However, you can enable it by accessing the Settings button and setting the `query_analyzer_enabled` flag to 1, then pressing Save. You can also adjust the `query_analyzer_threshold` flag to set the minimum threshold query time (in milliseconds) that triggers a query to be included in the Analyzer. If the default value is too low, it's recommended to increase it to avoid having too many queries included in the panel.
To test the Analyzer, we can go to the `Databases -> Chinook.sqlite -> Console` section and perform a query that filters the non-indexed Composer column of the Track table with the following statement: `SELECT * FROM Tracks WHERE Composer = 'AC/DC'`;
To test the Analyzer, we can go to the `Studio -> chinook.sqlite -> SQL Console` section and perform a query that filters the non-indexed Composer column of the Track table with the following statement: `SELECT * FROM Tracks WHERE Composer = 'AC/DC'`;
25
+
20
26
21
-
Once we have executed this query, we can go back to the Analyzer panel and see that it has been successfully analyzed by the **nemtfenosk** node.
27
+
Once we have executed this query, we can go back to the Analyzer panel and see that it has been successfully analyzed by the **nxidiwbuhz** node.
By selecting **Details** and **Plan**, we can get more in-depth information about the execution of this query over time. However, what we're most interested in is the intelligent recommendation, which can be found by selecting **Suggest**. In the Indexes field, we can find the optimal index to apply to our database, which will speed up all queries on the Track table filtered by the Composer column.
Edge functions let you define custom logic to run on the same nodes as your database files for ultra-fast performance.
12
14
13
15
You can write edge functions directly in the SQLite Cloud dashboard using JavaScript, TypeScript, or SQL. Importing modules is not currently supported.
@@ -18,68 +20,41 @@ Turning on linearizable reads ensures strong consistency, but may introduce some
18
20
19
21
## Getting Started
20
22
21
-
This guide explains how to create, deploy, and test Edge Functions in the SQLite Cloud UI.
22
-
23
-
<VideoPlayersrc={edgeFunctions} />
24
-
23
+
Use the **Edge Functions panel** to effortlessly create, deploy, and test Edge Functions directly in the SQLite Cloud dashboard.
24
+
The editor allows you to choose the language of your function — **JavaScript**, **TypeScript**, or **SQL** — and connect it to the database of your choice.
25
25
26
+
Once deployed, the function can be tested immediately in the dashboard or invoked externally through its Function URL.
26
27
27
-
1. Open the Edge Functions Section
28
-
- From the left-hand sidebar, click the **Edge Functions** icon.
29
-
- You will see the list of your functions on the left and the code editor on the right.
28
+
<VideoPlayersrc={edgeFunctions} />
30
29
31
-
2. Create a New Function
32
-
- Click the **+** button next to *Filter functions...*.
33
-
- Choose the function type: **SQL**, **JavaScript**, or **TypeScript**.
34
-
- A new function (e.g., `function-1`) will appear in the list.
30
+
#### Note:
31
+
Functions should return a JSON-serializable object with a data field:
32
+
```js
33
+
return {
34
+
data: {
35
+
// your return object
36
+
}
37
+
}
38
+
```
35
39
36
-
3. Write Your Function Code
37
-
- Use the editor to implement your logic.
38
-
- You can include request parameters, execute SQL queries, and return custom objects.
39
40
40
-
4. Select the Target Database
41
-
- At the bottom of the editor, choose the database (e.g., `chinook.sqlite`).
42
-
- You can search and switch databases if needed.
43
41
44
-
5. Deploy the Function
45
-
- Before testing, you must **Deploy** the function.
46
-
- Click the **Deploy** button in the bottom-right corner.
47
-
- The function is now active and ready to be tested.
42
+
<Callouttype="note">
43
+
Enabling **linearizable reads** guarantees strong consistency but may introduce additional latency.
44
+
For most cases, we recommend keeping it disabled to benefit from lower response times.
45
+
</Callout>
48
46
49
-
6. Test the Function
50
-
- After deployment, click **Test**.
51
-
- A panel will open on the right where you can configure:
52
-
-**User** → choose a user with access to the selected database.
53
-
-**API Key** → select the appropriate key.
54
-
-**Request Body** → provide JSON input (e.g., `{ "filter": "a" }`).
OffSync is a powerful SQLite Cloud feature that enables true **local-first** data synchronization for your applications. Powered by the [SQLite Sync](https://github.com/sqliteai/sqlite-sync) extension, it allows you to build robust, offline-capable applications where data is stored and processed on edge devices and seamlessly synchronized with a central SQLite Cloud database.
@@ -24,16 +31,28 @@ When combined with [Row-Level Security (RLS)](/docs/rls), OffSync allows you to
24
31
25
32
## Configuring OffSync
26
33
27
-
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
34
+
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
35
+
Below are the main steps:
36
+
37
+
### 1. Enable Tables for Synchronization
38
+
From the **Sync Tables** tab, select which tables in your database you want to keep synchronized.
39
+
Once enabled, all changes to those tables will automatically sync with connected devices.
40
+
41
+
<VideoPlayersrc={enableSync} />
42
+
43
+
44
+
### 2. Get the Connection String
45
+
In the **Configuration** tab, copy the connection string.
46
+
Use this in your application to initialize OffSync and connect your local SQLite database with SQLite Cloud.
28
47
29
-
1.**Navigate to the Databases Page**: From the main dashboard, go to the "Databases" page.
30
-
2.**Select the Offsync Column**: In the list of your databases, click on the button in the "Offsync" column for the desired database.
3.**Enable Tables for Synchronization**: On the Offsync settings page, you will see a list of all tables in your database. Toggle the switch next to each table you want to enable for synchronization.
51
+
### 3. Manage Connected Devices
52
+
In the **Devices** tab, you can view all devices currently connected to your database.
53
+
Here you can check their sync status and remove devices if needed.
<Callouttype="note"title="Matching Schemas and Tables">
39
58
For OffSync to work correctly, the list of tables configured for synchronization—and their corresponding schemas—must be identical in both your local SQLite database and your SQLite Cloud database.
Row-Level Security (RLS) allows you to define fine-grained access control policies that determine which rows in a table a user can access. This ensures that users can only view or modify data they are authorized to see, enhancing data security and privacy.
@@ -38,14 +44,12 @@ Otherwise, they will be blocked from accessing any rows.
38
44
39
45
You can configure RLS policies for your databases through the SQLite Cloud dashboard.
40
46
47
+
<VideoPlayersrc={rlsEnable} />
48
+
41
49
1.**Navigate to the Databases Page**: From the main dashboard, go to the "Databases" page.
42
50
2.**Select the RLS Column**: In the list of your databases, click on the button in the "RLS" column for the desired database.
For each table, you can specify the following RLS policies:
51
55
@@ -58,6 +62,31 @@ You can configure RLS policies for your databases through the SQLite Cloud dashb
58
62
The SQL expressions can be any valid SQLite expression that returns a boolean value. You can use built-in SQLite functions, and even custom functions to define your policies.
59
63
</Callout>
60
64
65
+
## Testing RLS
66
+
<VideoPlayersrc={rlsTest} />
67
+
68
+
To verify that your Row-Level Security (RLS) policies work as expected, you can use the **Test RLS** feature in the dashboard:
69
+
70
+
1.**Open the Test Panel**
71
+
On the RLS policies page, click **Test** to open the dedicated testing panel.
72
+
73
+
2.**Generate an Access Token**
74
+
- Go to the **Weblite page** and use the `POST /v2/tokens` endpoint.
75
+
- Provide a request body with a `userId`, a `name`, and any attributes required by your RLS policies (for example: `role`, `enabled`, etc.).
76
+
- Execute the request and copy the `token` value from the response.
77
+
78
+
3.**Authenticate in the Test Panel**
79
+
- Paste the generated token into the **Enter Access Token** field and click **Authorize**.
80
+
- The dashboard will now simulate queries to the database as if they were executed by the user identified in the token.
81
+
82
+
4.**View Filtered Data**
83
+
- Once authenticated, you can navigate through the database tables directly from the test panel.
84
+
- Only the rows allowed by your RLS rules will be displayed (for example, activities tied to the `user_id` in the token or accessible with the `coach` role).
85
+
86
+
5.**Compare with Full Data**
87
+
- By switching back to **Database Studio**, you can see all rows in the table without RLS filters.
88
+
- This allows you to compare the filtered view (via token) with the complete dataset and confirm that your policies are correctly enforced.
89
+
61
90
### User Information Functions
62
91
63
92
To help you create dynamic RLS policies, SQLite Cloud provides two functions to retrieve information about the current authenticated user:
Copy file name to clipboardExpand all lines: sqlite-cloud/platform/webhooks.mdx
+57-3Lines changed: 57 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ For example, you can configure SQLite Cloud to notify a [webhook.site](https://w
21
21
<VideoPlayersrc={webhooksUrl} />
22
22
23
23
24
+
24
25
## Change Data Capture
25
26
26
27
Change Data Webhooks let you send structured HTTP requests to any external service whenever a row in a specific database and/or table is modified. These webhooks include:
@@ -32,20 +33,73 @@ Change Data Webhooks let you send structured HTTP requests to any external servi
32
33
33
34
This enables seamless integration with logging systems, monitoring dashboards, or external APIs that react to database activity.
Webhooks in SQLite Cloud aren't limited to data capture—they can also **trigger Edge Functions**:
46
77
47
78
* Via HTTP or WebSocket
48
79
* In response to database write events
80
+
49
81
<VideoPlayersrc={webhooksEdgeFunction} />
50
82
83
+
Within an Edge Function, the webhook payload containing the **Change Data Capture** information is directly accessible through the `request.data` variable, which is available by default in all Edge Functions.
0 commit comments