Skip to content

Commit 907a67c

Browse files
committed
feat: add embedded database support for static deployments
Implements #10 Allows users to embed .db files at build time by placing them in public/databases/ directory. Perfect for deploying DuckUI with demo data or creating self-contained analytical dashboards. Features: - Auto-loads databases defined in public/databases/manifest.json - Fetches and registers .db files in DuckDB's virtual file system - Attaches databases automatically on startup - Graceful error handling with console logging - Full documentation in public/databases/README.md Usage: 1. Place .db files in public/databases/ 2. Add entry to manifest.json with name, file, description, autoLoad 3. Build and deploy - databases load automatically Example manifest.json: { "databases": [ { "name": "Demo DB", "file": "demo.db", "description": "Sample data", "autoLoad": true } ] }
1 parent 5584503 commit 907a67c

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

public/databases/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Embedded Databases
2+
3+
This directory allows you to embed DuckDB database files (`.db`) that will be automatically loaded when DuckUI starts. This is perfect for:
4+
5+
- Deploying DuckUI with demo data
6+
- Distributing pre-configured databases
7+
- Creating self-contained analytical dashboards
8+
9+
## How to Add Your Database
10+
11+
1. **Place your `.db` file in this directory**
12+
```
13+
public/databases/my-database.db
14+
```
15+
16+
2. **Register it in `manifest.json`**
17+
```json
18+
{
19+
"databases": [
20+
{
21+
"name": "My Database",
22+
"file": "my-database.db",
23+
"description": "Description of your database",
24+
"autoLoad": true
25+
}
26+
]
27+
}
28+
```
29+
30+
3. **Build and deploy**
31+
```bash
32+
bun run build
33+
```
34+
35+
## Manifest Format
36+
37+
Each database entry in `manifest.json` supports:
38+
39+
- **`name`** (required): Display name in the UI
40+
- **`file`** (required): Filename of the `.db` file in this directory
41+
- **`description`** (optional): Description shown in the UI
42+
- **`autoLoad`** (optional, default: `true`): Whether to load on startup
43+
44+
## Example
45+
46+
```json
47+
{
48+
"databases": [
49+
{
50+
"name": "Sales Demo",
51+
"file": "sales-demo.db",
52+
"description": "Sample sales data from 2023",
53+
"autoLoad": true
54+
},
55+
{
56+
"name": "Analytics",
57+
"file": "analytics.db",
58+
"description": "Web analytics data",
59+
"autoLoad": false
60+
}
61+
]
62+
}
63+
```
64+
65+
## Notes
66+
67+
- Database files are fetched and loaded in the browser
68+
- Large database files will increase initial load time
69+
- All databases are loaded into memory (consider file sizes)
70+
- You can attach/detach databases dynamically from the SQL editor

public/databases/manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"databases": []
3+
}

0 commit comments

Comments
 (0)