spindb 0.18.0 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +540 -861
- package/cli/commands/create.ts +156 -4
- package/cli/commands/engines.ts +69 -1
- package/cli/commands/menu/container-handlers.ts +113 -78
- package/cli/commands/menu/engine-handlers.ts +12 -0
- package/cli/commands/menu/index.ts +6 -2
- package/cli/commands/menu/shell-handlers.ts +13 -0
- package/cli/commands/run.ts +4 -4
- package/cli/constants.ts +1 -0
- package/cli/helpers.ts +102 -27
- package/cli/ui/prompts.ts +13 -9
- package/config/backup-formats.ts +16 -0
- package/config/engine-defaults.ts +14 -0
- package/config/engines.json +16 -0
- package/config/os-dependencies.ts +2 -1
- package/core/config-manager.ts +26 -0
- package/core/container-manager.ts +127 -17
- package/core/dependency-manager.ts +22 -0
- package/engines/base-engine.ts +8 -0
- package/engines/clickhouse/backup.ts +72 -15
- package/engines/clickhouse/binary-manager.ts +3 -2
- package/engines/clickhouse/binary-urls.ts +14 -3
- package/engines/clickhouse/hostdb-releases.ts +19 -4
- package/engines/clickhouse/index.ts +6 -4
- package/engines/clickhouse/restore.ts +8 -3
- package/engines/clickhouse/version-validator.ts +6 -5
- package/engines/duckdb/binary-manager.ts +473 -0
- package/engines/duckdb/binary-urls.ts +116 -0
- package/engines/duckdb/index.ts +689 -0
- package/engines/duckdb/registry.ts +303 -0
- package/engines/duckdb/version-maps.ts +65 -0
- package/engines/duckdb/version-validator.ts +78 -0
- package/engines/index.ts +4 -0
- package/engines/sqlite/binary-manager.ts +62 -14
- package/package.json +5 -4
- package/types/index.ts +41 -7
package/README.md
CHANGED
|
@@ -3,1159 +3,821 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/spindb)
|
|
4
4
|
[](https://www.npmjs.com/package/spindb)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](#platform-
|
|
6
|
+
[](#platform-coverage)
|
|
7
7
|
|
|
8
|
-
**
|
|
8
|
+
**One CLI for all your local databases.**
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Quick Start
|
|
10
|
+
SpinDB is a universal database management tool that combines a package manager, a unified API, and native client tooling for 9 different database engines—all from a single command-line interface. No Docker, no VMs, no platform-specific installers. Just databases, running natively on your machine.
|
|
15
11
|
|
|
16
12
|
```bash
|
|
17
|
-
# Install globally (or use pnpm/yarn)
|
|
18
13
|
npm install -g spindb
|
|
19
14
|
|
|
20
|
-
#
|
|
21
|
-
spindb create
|
|
22
|
-
|
|
23
|
-
# Connect to it
|
|
24
|
-
spindb connect myapp
|
|
25
|
-
|
|
26
|
-
# You're in! Run some SQL:
|
|
27
|
-
# postgres=# CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
That's it. Your database is running on `localhost:5432`, and your data persists in `~/.spindb/containers/postgresql/myapp/`.
|
|
15
|
+
# PostgreSQL for your API
|
|
16
|
+
spindb create api-db
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Why SpinDB?
|
|
35
|
-
|
|
36
|
-
Docker is great for production parity and complex multi-service setups. But for local development databases, it's often overkill:
|
|
37
|
-
|
|
38
|
-
- **Resource overhead** - Docker Desktop runs a Linux VM on macOS/Windows
|
|
39
|
-
- **Complexity** - Volumes, networks, compose files for a single database
|
|
40
|
-
- **Startup time** - Container initialization vs native process launch
|
|
41
|
-
- **Licensing** - Docker Desktop requires a paid subscription for larger organizations
|
|
42
|
-
|
|
43
|
-
Sometimes you just want PostgreSQL on `localhost:5432` without the ceremony.
|
|
44
|
-
|
|
45
|
-
SpinDB runs databases as native processes with isolated data directories. No VM, no daemon, no container networking. Just databases.
|
|
46
|
-
|
|
47
|
-
### SpinDB vs Alternatives
|
|
48
|
-
|
|
49
|
-
| Feature | SpinDB | Docker | DBngin | Postgres.app | XAMPP |
|
|
50
|
-
|---------|--------|--------|--------|--------------|-------|
|
|
51
|
-
| No Docker required | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
52
|
-
| Multiple DB engines | ✅ | ✅ | ✅ | ❌ | ⚠️ MySQL only |
|
|
53
|
-
| CLI-first | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
54
|
-
| Multiple versions | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
55
|
-
| Clone databases | ✅ | Manual | ✅ | ❌ | ❌ |
|
|
56
|
-
| Low resource usage | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
57
|
-
| Linux support | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
58
|
-
| Free | ✅ | ⚠️ | ✅ | ✅ | ✅ |
|
|
18
|
+
# MongoDB for analytics
|
|
19
|
+
spindb create analytics --engine mongodb
|
|
59
20
|
|
|
60
|
-
|
|
21
|
+
# Redis for caching
|
|
22
|
+
spindb create cache --engine redis
|
|
61
23
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
| macOS (ARM64) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
65
|
-
| macOS (Intel) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
66
|
-
| Linux (x64) | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
67
|
-
| Linux (ARM64) | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
68
|
-
| Windows (x64) | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
24
|
+
# All running side-by-side, all managed the same way
|
|
25
|
+
```
|
|
69
26
|
|
|
70
27
|
---
|
|
71
28
|
|
|
72
|
-
##
|
|
29
|
+
## What is SpinDB?
|
|
73
30
|
|
|
74
|
-
SpinDB is
|
|
31
|
+
SpinDB is **three tools in one**:
|
|
75
32
|
|
|
76
|
-
|
|
33
|
+
### 1. **Database Package Manager**
|
|
34
|
+
Download and manage multiple database engines and versions—just like `apt`, `brew`, or `npm`, but for databases.
|
|
77
35
|
|
|
78
36
|
```bash
|
|
79
|
-
#
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
# Using npm
|
|
83
|
-
npm install -g spindb
|
|
37
|
+
# Run PostgreSQL 14 for legacy projects, 18 for new ones
|
|
38
|
+
spindb create old-project --engine postgresql --db-version 14
|
|
39
|
+
spindb create new-project --engine postgresql --db-version 18
|
|
84
40
|
|
|
85
|
-
# Or
|
|
86
|
-
|
|
87
|
-
|
|
41
|
+
# Or MySQL 8.0 alongside MySQL 9
|
|
42
|
+
spindb create legacy-mysql --engine mysql --db-version 8.0
|
|
43
|
+
spindb create modern-mysql --engine mysql --db-version 9
|
|
88
44
|
```
|
|
89
45
|
|
|
90
|
-
###
|
|
91
|
-
|
|
92
|
-
SpinDB checks for updates automatically and notifies you when a new version is available.
|
|
46
|
+
### 2. **Unified Database API**
|
|
47
|
+
One consistent interface across SQL databases, document stores, key-value stores, and analytics engines.
|
|
93
48
|
|
|
94
49
|
```bash
|
|
95
|
-
#
|
|
96
|
-
spindb
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
spindb
|
|
100
|
-
|
|
101
|
-
# Disable automatic update checks
|
|
102
|
-
spindb config update-check off
|
|
50
|
+
# Same commands work for ANY database
|
|
51
|
+
spindb create mydb --engine [postgresql|mysql|mariadb|mongodb|redis|valkey|clickhouse|sqlite|duckdb]
|
|
52
|
+
spindb start mydb
|
|
53
|
+
spindb connect mydb
|
|
54
|
+
spindb backup mydb
|
|
55
|
+
spindb restore mydb backup.dump
|
|
103
56
|
```
|
|
104
57
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## The Interactive Menu
|
|
108
|
-
|
|
109
|
-
Most of the time, you don't need to remember commands. Just run:
|
|
58
|
+
### 3. **Native Database Client**
|
|
59
|
+
Access built-in shells, run queries, and execute scripts—all without installing separate clients.
|
|
110
60
|
|
|
111
61
|
```bash
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
? What would you like to do?
|
|
119
|
-
❯ Create a new container
|
|
120
|
-
Manage containers
|
|
121
|
-
View installed engines
|
|
122
|
-
Check dependencies
|
|
123
|
-
Settings
|
|
124
|
-
Exit
|
|
62
|
+
# Execute SQL/NoSQL/commands across any engine
|
|
63
|
+
spindb run mydb script.sql # PostgreSQL/MySQL/SQLite
|
|
64
|
+
spindb run mydb -c "db.users.find().pretty()" # MongoDB
|
|
65
|
+
spindb run mydb -c "SET mykey myvalue" # Redis/Valkey
|
|
66
|
+
spindb run mydb -c "SELECT * FROM system.tables" # ClickHouse
|
|
125
67
|
```
|
|
126
68
|
|
|
127
|
-
**Everything in the menu is also available as a CLI command.** The menu is just a friendlier interface for the same operations. If you prefer typing commands or scripting, SpinDB has full CLI support.
|
|
128
|
-
|
|
129
69
|
---
|
|
130
70
|
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
### Supported Engines
|
|
134
|
-
|
|
135
|
-
#### PostgreSQL
|
|
136
|
-
|
|
137
|
-
| | |
|
|
138
|
-
|---|---|
|
|
139
|
-
| Versions | 15, 16, 17, 18 |
|
|
140
|
-
| Default port | 5432 |
|
|
141
|
-
| Default user | `postgres` |
|
|
142
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) (macOS/Linux), [EDB](https://www.enterprisedb.com/) (Windows) |
|
|
143
|
-
|
|
144
|
-
SpinDB downloads PostgreSQL server binaries automatically:
|
|
145
|
-
- **macOS/Linux:** Pre-compiled binaries from [hostdb](https://github.com/robertjbass/hostdb) on GitHub Releases
|
|
146
|
-
- **Windows:** Official binaries from EnterpriseDB (EDB)
|
|
71
|
+
## Platform Coverage
|
|
147
72
|
|
|
148
|
-
|
|
73
|
+
SpinDB works across **9 database engines** and **5 platform architectures** with a **single, consistent API**.
|
|
149
74
|
|
|
150
|
-
|
|
75
|
+
| Database | macOS ARM64 | macOS Intel | Linux x64 | Linux ARM64 | Windows x64 |
|
|
76
|
+
|----------|:-----------:|:-----------:|:---------:|:-----------:|:-----------:|
|
|
77
|
+
| 🐘 **PostgreSQL** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
78
|
+
| 🐬 **MySQL** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
79
|
+
| 🦭 **MariaDB** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
80
|
+
| 🪶 **SQLite** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
81
|
+
| 🦆 **DuckDB** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
82
|
+
| 🍃 **MongoDB** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
83
|
+
| 🔴 **Redis** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
84
|
+
| 🔷 **Valkey** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
85
|
+
| 🏠 **ClickHouse** | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
86
|
+
|
|
87
|
+
**44 combinations. One CLI. Zero configuration.**
|
|
151
88
|
|
|
152
|
-
|
|
89
|
+
---
|
|
153
90
|
|
|
154
|
-
|
|
155
|
-
|---|---|
|
|
156
|
-
| Versions | 10.11, 11.4, 11.8 |
|
|
157
|
-
| Default port | 3307 |
|
|
158
|
-
| Default user | `root` |
|
|
159
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
91
|
+
## Quick Start
|
|
160
92
|
|
|
161
|
-
SpinDB
|
|
93
|
+
Install SpinDB globally using your preferred package manager:
|
|
162
94
|
|
|
163
95
|
```bash
|
|
164
|
-
#
|
|
165
|
-
|
|
96
|
+
# Using npm
|
|
97
|
+
npm install -g spindb
|
|
166
98
|
|
|
167
|
-
#
|
|
168
|
-
|
|
99
|
+
# Using pnpm (recommended - faster, more efficient)
|
|
100
|
+
pnpm add -g spindb
|
|
169
101
|
|
|
170
|
-
#
|
|
171
|
-
spindb
|
|
102
|
+
# Or run without installing
|
|
103
|
+
npx spindb
|
|
172
104
|
```
|
|
173
105
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
#### MySQL
|
|
177
|
-
|
|
178
|
-
| | |
|
|
179
|
-
|---|---|
|
|
180
|
-
| Versions | 8.0, 8.4, 9 |
|
|
181
|
-
| Default port | 3306 |
|
|
182
|
-
| Default user | `root` |
|
|
183
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
184
|
-
|
|
185
|
-
SpinDB downloads MySQL server binaries automatically from [hostdb](https://github.com/robertjbass/hostdb) on GitHub Releases—just like PostgreSQL and MariaDB. This provides multi-version support and works across all platforms.
|
|
106
|
+
Create and start a database in seconds:
|
|
186
107
|
|
|
187
108
|
```bash
|
|
188
|
-
#
|
|
189
|
-
spindb create
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
spindb create mydb --engine mysql --version 8.0
|
|
109
|
+
# PostgreSQL (default engine)
|
|
110
|
+
spindb create myapp
|
|
111
|
+
spindb start myapp
|
|
112
|
+
spindb connect myapp
|
|
193
113
|
|
|
194
|
-
#
|
|
195
|
-
spindb
|
|
114
|
+
# Or all in one command
|
|
115
|
+
spindb create myapp --start --connect
|
|
196
116
|
```
|
|
197
117
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#### SQLite
|
|
118
|
+
That's it! Your PostgreSQL database is now running on `localhost:5432`, and data persists in `~/.spindb/containers/postgresql/myapp/`.
|
|
201
119
|
|
|
202
|
-
|
|
203
|
-
|---|---|
|
|
204
|
-
| Version | 3 |
|
|
205
|
-
| Default port | N/A (file-based) |
|
|
206
|
-
| Data location | Project directory (CWD) |
|
|
207
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
208
|
-
|
|
209
|
-
SQLite is a file-based database—no server process, no ports. Databases are stored in your project directory by default, not `~/.spindb/`. SpinDB tracks registered SQLite databases in a registry file.
|
|
210
|
-
|
|
211
|
-
**Tools included:** SQLite binaries include `sqlite3`, `sqldiff`, `sqlite3_analyzer`, and `sqlite3_rsync`. No system installation required.
|
|
120
|
+
### Try Other Engines
|
|
212
121
|
|
|
213
122
|
```bash
|
|
214
|
-
#
|
|
215
|
-
spindb create
|
|
123
|
+
# MySQL for relational data
|
|
124
|
+
spindb create shop --engine mysql --start --connect
|
|
216
125
|
|
|
217
|
-
#
|
|
218
|
-
spindb create
|
|
126
|
+
# MongoDB for document storage
|
|
127
|
+
spindb create logs --engine mongodb --start
|
|
219
128
|
|
|
220
|
-
#
|
|
221
|
-
spindb
|
|
129
|
+
# Redis for caching and real-time features
|
|
130
|
+
spindb create sessions --engine redis --start
|
|
222
131
|
|
|
223
|
-
#
|
|
224
|
-
spindb
|
|
132
|
+
# DuckDB for analytics
|
|
133
|
+
spindb create analytics --engine duckdb --start
|
|
225
134
|
```
|
|
226
135
|
|
|
227
|
-
|
|
136
|
+
Every engine works the same way. Learn one, use them all.
|
|
228
137
|
|
|
229
|
-
|
|
138
|
+
---
|
|
230
139
|
|
|
231
|
-
|
|
232
|
-
|---|---|
|
|
233
|
-
| Versions | 7.0, 8.0, 8.2 |
|
|
234
|
-
| Default port | 27017 |
|
|
235
|
-
| Default user | None (no auth by default) |
|
|
236
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
140
|
+
## Why SpinDB?
|
|
237
141
|
|
|
238
|
-
|
|
142
|
+
### The Problem with Current Tools
|
|
239
143
|
|
|
240
|
-
|
|
241
|
-
# Create a MongoDB container (downloads binaries automatically)
|
|
242
|
-
spindb create mydb --engine mongodb
|
|
144
|
+
**Docker** is powerful but heavy—requires a daemon, runs containers in a VM (on macOS/Windows), and adds complexity for simple local databases.
|
|
243
145
|
|
|
244
|
-
|
|
245
|
-
spindb create mydb --engine mongodb --version 8.0
|
|
146
|
+
**GUI tools** like DBngin and Postgres.app are great but platform-specific, don't support scripting, and lack a unified interface across engines.
|
|
246
147
|
|
|
247
|
-
|
|
248
|
-
spindb deps check --engine mongodb
|
|
249
|
-
```
|
|
148
|
+
**System package managers** (brew, apt, etc.) work but create version conflicts, require manual configuration, and don't provide consistent management across databases.
|
|
250
149
|
|
|
251
|
-
|
|
150
|
+
### SpinDB's Approach
|
|
252
151
|
|
|
253
|
-
|
|
254
|
-
# Insert a document
|
|
255
|
-
spindb run mydb -c "db.users.insertOne({name: 'Alice', email: 'alice@example.com'})"
|
|
152
|
+
SpinDB runs databases as **native processes** with **isolated data directories**:
|
|
256
153
|
|
|
257
|
-
|
|
258
|
-
|
|
154
|
+
- **No Docker daemon or VM overhead** - Direct process execution
|
|
155
|
+
- **No system installation conflicts** - Each database version lives in `~/.spindb/bin/`
|
|
156
|
+
- **No manual configuration** - Databases start with sensible defaults
|
|
157
|
+
- **Cross-platform consistency** - Same commands work on macOS, Linux, and Windows
|
|
158
|
+
- **Multi-version support** - Run PostgreSQL 14 and 18 side-by-side
|
|
159
|
+
- **Unified interface** - Manage PostgreSQL, MongoDB, and Redis the same way
|
|
259
160
|
|
|
260
|
-
|
|
261
|
-
spindb run mydb --file ./scripts/seed.js
|
|
262
|
-
```
|
|
161
|
+
### Comparison Matrix
|
|
263
162
|
|
|
264
|
-
|
|
163
|
+
| Feature | SpinDB | Docker | DBngin | Postgres.app | XAMPP |
|
|
164
|
+
|---------|--------|--------|--------|--------------|-------|
|
|
165
|
+
| No Docker required | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
166
|
+
| Multiple DB engines | ✅ 9 engines | ✅ Unlimited | ✅ 3 engines | ❌ PostgreSQL only | ⚠️ MySQL only |
|
|
167
|
+
| CLI-first | ✅ | ✅ | ❌ GUI-first | ❌ GUI-first | ❌ GUI-first |
|
|
168
|
+
| Multiple versions | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
169
|
+
| Clone databases | ✅ | Manual | ✅ | ❌ | ❌ |
|
|
170
|
+
| Backup/restore built-in | ✅ | Manual | ✅ | ❌ | ❌ |
|
|
171
|
+
| Low resource usage | ✅ Native | ❌ VM on macOS/Win | ✅ Native | ✅ Native | ✅ Native |
|
|
172
|
+
| Linux support | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
173
|
+
| ARM64 support | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
174
|
+
| Free for commercial use | ❌ | ⚠️ Paid for orgs | ✅ | ✅ | ✅ |
|
|
265
175
|
|
|
266
|
-
|
|
267
|
-
|---|---|
|
|
268
|
-
| Versions | 7, 8 |
|
|
269
|
-
| Default port | 6379 |
|
|
270
|
-
| Default user | None (no auth by default) |
|
|
271
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
176
|
+
---
|
|
272
177
|
|
|
273
|
-
|
|
178
|
+
## Supported Databases
|
|
274
179
|
|
|
275
|
-
|
|
276
|
-
# Create a Redis container (downloads binaries automatically)
|
|
277
|
-
spindb create mydb --engine redis
|
|
180
|
+
SpinDB supports **9 database engines** with **multiple versions** for each:
|
|
278
181
|
|
|
279
|
-
|
|
280
|
-
|
|
182
|
+
| Engine | Type | Versions | Default Port | Query Language |
|
|
183
|
+
|--------|------|----------|--------------|----------------|
|
|
184
|
+
| 🐘 **PostgreSQL** | Relational (SQL) | 15, 16, 17, 18 | 5432 | SQL |
|
|
185
|
+
| 🐬 **MySQL** | Relational (SQL) | 8.0, 8.4, 9 | 3306 | SQL |
|
|
186
|
+
| 🦭 **MariaDB** | Relational (SQL) | 10.11, 11.4, 11.8 | 3307 | SQL |
|
|
187
|
+
| 🪶 **SQLite** | Embedded (SQL) | 3 | N/A (file-based) | SQL |
|
|
188
|
+
| 🦆 **DuckDB** | Embedded OLAP | 1.4.3 | N/A (file-based) | SQL |
|
|
189
|
+
| 🍃 **MongoDB** | Document Store | 7.0, 8.0, 8.2 | 27017 | JavaScript (mongosh) |
|
|
190
|
+
| 🔴 **Redis** | Key-Value Store | 7, 8 | 6379 | Redis commands |
|
|
191
|
+
| 🔷 **Valkey** | Key-Value Store | 8, 9 | 6379 | Redis commands |
|
|
192
|
+
| 🏠 **ClickHouse** | Columnar OLAP | 25.12 | 9000 (TCP), 8123 (HTTP) | SQL (ClickHouse dialect) |
|
|
281
193
|
|
|
282
|
-
|
|
283
|
-
spindb deps check --engine redis
|
|
284
|
-
```
|
|
194
|
+
### Engine Categories
|
|
285
195
|
|
|
286
|
-
|
|
196
|
+
**Server-Based Databases** (PostgreSQL, MySQL, MariaDB, MongoDB, Redis, Valkey, ClickHouse):
|
|
197
|
+
- Start/stop server processes
|
|
198
|
+
- Bind to localhost ports
|
|
199
|
+
- Data stored in `~/.spindb/containers/{engine}/{name}/`
|
|
287
200
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
201
|
+
**File-Based Databases** (SQLite, DuckDB):
|
|
202
|
+
- No server process required
|
|
203
|
+
- Data stored in your project directories
|
|
204
|
+
- Always "running" (embedded, no daemon)
|
|
291
205
|
|
|
292
|
-
|
|
293
|
-
spindb run myredis -c "GET mykey"
|
|
206
|
+
### Binary Sources
|
|
294
207
|
|
|
295
|
-
|
|
296
|
-
spindb run myredis --file ./scripts/seed.redis
|
|
208
|
+
All engines download pre-compiled binaries from [**hostdb**](https://github.com/robertjbass/hostdb), a repository of portable database binaries for all major platforms:
|
|
297
209
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
```
|
|
210
|
+
- **PostgreSQL**: hostdb (macOS/Linux), [EnterpriseDB](https://www.enterprisedb.com/) (Windows)
|
|
211
|
+
- **All other engines**: hostdb (all supported platforms)
|
|
301
212
|
|
|
302
|
-
|
|
213
|
+
This enables **multi-version support** without system package conflicts. Run PostgreSQL 14 for legacy projects and 18 for new ones—simultaneously.
|
|
303
214
|
|
|
304
|
-
|
|
215
|
+
---
|
|
305
216
|
|
|
306
|
-
|
|
307
|
-
|---|---|
|
|
308
|
-
| Versions | 8, 9 |
|
|
309
|
-
| Default port | 6379 |
|
|
310
|
-
| Default user | None (no auth by default) |
|
|
311
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
217
|
+
## Core Commands
|
|
312
218
|
|
|
313
|
-
|
|
219
|
+
SpinDB provides a comprehensive CLI with commands for every database lifecycle operation.
|
|
314
220
|
|
|
315
|
-
|
|
221
|
+
### Container Lifecycle
|
|
316
222
|
|
|
317
223
|
```bash
|
|
318
|
-
# Create a
|
|
319
|
-
spindb create mydb
|
|
224
|
+
# Create a new database
|
|
225
|
+
spindb create mydb # PostgreSQL (default)
|
|
226
|
+
spindb create mydb --engine mongodb # MongoDB
|
|
227
|
+
spindb create mydb --engine mysql --db-version 8.0 # MySQL 8.0
|
|
228
|
+
spindb create mydb --port 5433 # Custom port
|
|
229
|
+
spindb create mydb --start --connect # Create, start, and connect
|
|
320
230
|
|
|
321
|
-
#
|
|
322
|
-
spindb
|
|
231
|
+
# Start/stop databases
|
|
232
|
+
spindb start mydb
|
|
233
|
+
spindb stop mydb
|
|
323
234
|
|
|
324
|
-
#
|
|
325
|
-
spindb
|
|
235
|
+
# Delete database (with confirmation)
|
|
236
|
+
spindb delete mydb
|
|
237
|
+
spindb delete mydb --yes --force # Skip prompts, force stop
|
|
326
238
|
```
|
|
327
239
|
|
|
328
|
-
|
|
240
|
+
### Data Operations
|
|
329
241
|
|
|
330
242
|
```bash
|
|
331
|
-
#
|
|
332
|
-
spindb
|
|
243
|
+
# Connect to database shell
|
|
244
|
+
spindb connect mydb # Standard client (psql, mysql, etc.)
|
|
245
|
+
spindb connect mydb --pgcli # Enhanced PostgreSQL shell
|
|
246
|
+
spindb connect mydb --mycli # Enhanced MySQL shell
|
|
247
|
+
spindb connect mydb --tui # Universal SQL client (usql)
|
|
333
248
|
|
|
334
|
-
#
|
|
335
|
-
spindb run
|
|
249
|
+
# Execute queries and scripts
|
|
250
|
+
spindb run mydb script.sql # Run SQL file
|
|
251
|
+
spindb run mydb -c "SELECT * FROM users" # Inline SQL
|
|
252
|
+
spindb run mydb seed.js # JavaScript (MongoDB)
|
|
253
|
+
spindb run mydb -c "SET foo bar" # Redis command
|
|
336
254
|
|
|
337
|
-
#
|
|
338
|
-
spindb
|
|
255
|
+
# Get connection string
|
|
256
|
+
spindb url mydb # postgresql://postgres@localhost:5432/mydb
|
|
257
|
+
spindb url mydb --copy # Copy to clipboard
|
|
258
|
+
spindb url mydb --json # JSON output with details
|
|
339
259
|
|
|
340
|
-
# Use
|
|
341
|
-
spindb
|
|
260
|
+
# Use in scripts
|
|
261
|
+
export DATABASE_URL=$(spindb url mydb)
|
|
262
|
+
psql $(spindb url mydb)
|
|
342
263
|
```
|
|
343
264
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
#### ClickHouse
|
|
347
|
-
|
|
348
|
-
| | |
|
|
349
|
-
|---|---|
|
|
350
|
-
| Versions | 25.12 |
|
|
351
|
-
| Default port | 9000 (native TCP), 8123 (HTTP) |
|
|
352
|
-
| Default user | `default` |
|
|
353
|
-
| Binary source | [hostdb](https://github.com/robertjbass/hostdb) |
|
|
354
|
-
|
|
355
|
-
ClickHouse is a column-oriented OLAP database designed for fast analytics on large datasets. SpinDB downloads ClickHouse server binaries automatically from [hostdb](https://github.com/robertjbass/hostdb) on GitHub Releases.
|
|
356
|
-
|
|
357
|
-
**Note:** ClickHouse is only available on macOS and Linux. Windows is not supported.
|
|
265
|
+
### Backup & Restore
|
|
358
266
|
|
|
359
267
|
```bash
|
|
360
|
-
# Create
|
|
361
|
-
spindb
|
|
268
|
+
# Create backups
|
|
269
|
+
spindb backup mydb # Auto-generated filename
|
|
270
|
+
spindb backup mydb --name production-backup # Custom name
|
|
271
|
+
spindb backup mydb --output ./backups/ # Custom directory
|
|
272
|
+
spindb backup mydb --format sql # SQL text format
|
|
273
|
+
spindb backup mydb --format dump # Binary format
|
|
362
274
|
|
|
363
|
-
#
|
|
364
|
-
spindb
|
|
275
|
+
# Restore from backups
|
|
276
|
+
spindb restore mydb backup.dump
|
|
277
|
+
spindb restore mydb backup.sql --database prod_copy
|
|
278
|
+
|
|
279
|
+
# Pull from remote database
|
|
280
|
+
spindb restore mydb --from-url "postgresql://user:pass@prod-host/db"
|
|
365
281
|
|
|
366
|
-
#
|
|
367
|
-
spindb
|
|
282
|
+
# Clone existing database
|
|
283
|
+
spindb create prod-copy --from ./prod-backup.dump
|
|
284
|
+
spindb create staging --from "postgresql://user:pass@prod:5432/production"
|
|
368
285
|
```
|
|
369
286
|
|
|
370
|
-
|
|
287
|
+
### Container Management
|
|
371
288
|
|
|
372
289
|
```bash
|
|
373
|
-
#
|
|
374
|
-
spindb
|
|
290
|
+
# List all databases
|
|
291
|
+
spindb list
|
|
292
|
+
spindb list --json
|
|
375
293
|
|
|
376
|
-
#
|
|
377
|
-
spindb
|
|
294
|
+
# Show container details
|
|
295
|
+
spindb info mydb
|
|
296
|
+
spindb info mydb --json
|
|
378
297
|
|
|
379
|
-
#
|
|
380
|
-
spindb
|
|
298
|
+
# Clone a database
|
|
299
|
+
spindb clone source-db new-db
|
|
381
300
|
|
|
382
|
-
#
|
|
383
|
-
spindb
|
|
301
|
+
# Edit configuration
|
|
302
|
+
spindb edit mydb --name newname # Rename
|
|
303
|
+
spindb edit mydb --port 5433 # Change port
|
|
304
|
+
spindb edit mydb --relocate ~/new/path # Move SQLite/DuckDB file
|
|
305
|
+
|
|
306
|
+
# View logs
|
|
307
|
+
spindb logs mydb
|
|
308
|
+
spindb logs mydb --follow # Follow mode (tail -f)
|
|
309
|
+
spindb logs mydb -n 100 # Last 100 lines
|
|
384
310
|
```
|
|
385
311
|
|
|
386
|
-
###
|
|
312
|
+
### Engine & System Management
|
|
387
313
|
|
|
388
|
-
|
|
314
|
+
```bash
|
|
315
|
+
# Manage installed engines
|
|
316
|
+
spindb engines # List installed engines
|
|
317
|
+
spindb engines supported # Show all supported engines
|
|
318
|
+
spindb engines delete postgresql 16 # Remove specific version
|
|
389
319
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
| 🟪 | Planned for hostdb (pending/in-progress) |
|
|
320
|
+
# Manage client tools
|
|
321
|
+
spindb deps check # Check all dependencies
|
|
322
|
+
spindb deps check --engine postgresql # Check specific engine
|
|
323
|
+
spindb deps install # Install missing tools
|
|
395
324
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
| MySQL | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
401
|
-
| MariaDB | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
402
|
-
| SQLite | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
403
|
-
| MongoDB* | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
404
|
-
| Redis* | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
405
|
-
| Valkey | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
406
|
-
| ClickHouse* | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
407
|
-
| **Planned for hostdb** |||||
|
|
408
|
-
| CockroachDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
409
|
-
| TimescaleDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
410
|
-
| DuckDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
411
|
-
| Meilisearch | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
412
|
-
| OpenSearch | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
413
|
-
| QuestDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
414
|
-
| FerretDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
415
|
-
| TiDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
416
|
-
| ArangoDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
417
|
-
| Qdrant | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
418
|
-
| Apache Cassandra | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
419
|
-
| InfluxDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
420
|
-
| CouchDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
421
|
-
| KeyDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
422
|
-
| libSQL | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
423
|
-
| FoundationDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
424
|
-
| RocksDB | 🟪 | 🟪 | 🟪 | 🟪 | 🟪 |
|
|
425
|
-
|
|
426
|
-
**Notes:**
|
|
427
|
-
- **\*** Licensing considerations for commercial use — consider Valkey (Redis) or FerretDB (MongoDB) as alternatives
|
|
428
|
-
- **PostgreSQL** uses [EDB](https://www.enterprisedb.com/) binaries on Windows instead of hostdb
|
|
429
|
-
- **ClickHouse** Windows binaries are not available on hostdb (macOS and Linux only)
|
|
430
|
-
- **Valkey** is a Redis-compatible drop-in replacement with permissive licensing
|
|
431
|
-
- **CockroachDB** is planned for both hostdb and SpinDB (see [roadmap](TODO.md))
|
|
432
|
-
- All databases under "Planned for hostdb" have permissive open-source licenses (Apache 2.0, MIT, or BSD)
|
|
433
|
-
|
|
434
|
-
For the latest platform support, see the [hostdb databases.json](https://github.com/robertjbass/hostdb/blob/main/databases.json).
|
|
325
|
+
# Configuration
|
|
326
|
+
spindb config show # Show current config
|
|
327
|
+
spindb config detect # Re-detect tool paths
|
|
328
|
+
spindb config update-check on # Enable update notifications
|
|
435
329
|
|
|
436
|
-
|
|
330
|
+
# System health
|
|
331
|
+
spindb doctor # Interactive health check
|
|
332
|
+
spindb doctor --json # JSON output
|
|
437
333
|
|
|
438
|
-
|
|
334
|
+
# Version management
|
|
335
|
+
spindb version # Show current version
|
|
336
|
+
spindb version --check # Check for updates
|
|
337
|
+
spindb self-update # Update to latest version
|
|
338
|
+
```
|
|
439
339
|
|
|
440
|
-
###
|
|
340
|
+
### Interactive Menu
|
|
441
341
|
|
|
442
|
-
|
|
342
|
+
Don't want to remember commands? Just run:
|
|
443
343
|
|
|
444
344
|
```bash
|
|
445
|
-
spindb
|
|
446
|
-
spindb create mydb --engine mariadb # MariaDB
|
|
447
|
-
spindb create mydb --engine mysql # MySQL
|
|
448
|
-
spindb create mydb --engine sqlite # SQLite (file-based)
|
|
449
|
-
spindb create mydb --db-version 16 # Specific PostgreSQL version
|
|
450
|
-
spindb create mydb --port 5433 # Custom port
|
|
451
|
-
spindb create mydb --database my_app # Custom database name
|
|
452
|
-
spindb create mydb --no-start # Create without starting
|
|
453
|
-
|
|
454
|
-
# Create, start, and connect in one command
|
|
455
|
-
spindb create mydb --start --connect
|
|
456
|
-
|
|
457
|
-
# SQLite with custom path
|
|
458
|
-
spindb create mydb --engine sqlite --path ./data/app.sqlite
|
|
345
|
+
spindb
|
|
459
346
|
```
|
|
460
347
|
|
|
461
|
-
|
|
348
|
+
You'll get an interactive menu with arrow-key navigation for all operations. **The menu is just a friendlier interface—everything is also available as a direct CLI command.**
|
|
462
349
|
|
|
463
|
-
|
|
464
|
-
spindb create mydb --from ./backup.dump
|
|
465
|
-
spindb create mydb --from "postgresql://user:pass@host:5432/production"
|
|
466
|
-
```
|
|
350
|
+
---
|
|
467
351
|
|
|
468
|
-
|
|
469
|
-
<summary>All options</summary>
|
|
352
|
+
## How It Works
|
|
470
353
|
|
|
471
|
-
|
|
472
|
-
|--------|-------------|
|
|
473
|
-
| `--engine`, `-e` | Database engine (`postgresql`, `mariadb`, `mysql`, `sqlite`, `mongodb`, `redis`, `valkey`) |
|
|
474
|
-
| `--db-version` | Engine version (e.g., 17 for PostgreSQL, 11.8 for MariaDB, 8 for Redis, 9 for Valkey) |
|
|
475
|
-
| `--port`, `-p` | Port number (not applicable for SQLite) |
|
|
476
|
-
| `--database`, `-d` | Primary database name (Redis uses 0-15) |
|
|
477
|
-
| `--path` | File path for SQLite databases |
|
|
478
|
-
| `--max-connections` | Maximum database connections (default: 200) |
|
|
479
|
-
| `--from` | Restore from backup file or connection string |
|
|
480
|
-
| `--start` | Start container after creation (skip prompt) |
|
|
481
|
-
| `--no-start` | Create without starting |
|
|
482
|
-
| `--connect` | Open a shell connection after creation |
|
|
354
|
+
### Architecture
|
|
483
355
|
|
|
484
|
-
|
|
356
|
+
SpinDB uses "container" terminology loosely—there's no Docker involved. When you create a container, SpinDB:
|
|
485
357
|
|
|
486
|
-
|
|
358
|
+
1. **Downloads database binaries** from [hostdb](https://github.com/robertjbass/hostdb) or uses system installations
|
|
359
|
+
2. **Creates isolated data directories** at `~/.spindb/containers/{engine}/{name}/`
|
|
360
|
+
3. **Runs databases as native processes** on your machine
|
|
487
361
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
362
|
+
Each container contains:
|
|
363
|
+
- `container.json` - Configuration (port, version, status)
|
|
364
|
+
- `data/` - Database files
|
|
365
|
+
- `{engine}.log` - Server logs
|
|
491
366
|
|
|
492
|
-
|
|
367
|
+
### Storage Layout
|
|
493
368
|
|
|
494
369
|
```bash
|
|
495
|
-
spindb
|
|
370
|
+
~/.spindb/
|
|
371
|
+
├── bin/ # Downloaded binaries
|
|
372
|
+
│ ├── postgresql-18.1.0-darwin-arm64/ # ~45 MB
|
|
373
|
+
│ ├── mysql-9.0.1-darwin-arm64/ # ~200 MB
|
|
374
|
+
│ └── mongodb-8.0-darwin-arm64/ # ~200 MB
|
|
375
|
+
├── containers/ # Server-based databases
|
|
376
|
+
│ ├── postgresql/
|
|
377
|
+
│ │ └── myapp/
|
|
378
|
+
│ │ ├── container.json
|
|
379
|
+
│ │ ├── data/
|
|
380
|
+
│ │ └── postgres.log
|
|
381
|
+
│ ├── mysql/
|
|
382
|
+
│ └── mongodb/
|
|
383
|
+
├── logs/ # SpinDB error logs
|
|
384
|
+
└── config.json # Tool paths and settings
|
|
385
|
+
|
|
386
|
+
# File-based databases (SQLite, DuckDB) store in project directories
|
|
387
|
+
./myproject/
|
|
388
|
+
└── app.sqlite # Created with: spindb create app -e sqlite
|
|
496
389
|
```
|
|
497
390
|
|
|
498
|
-
|
|
391
|
+
### Data Persistence
|
|
499
392
|
|
|
500
|
-
|
|
501
|
-
spindb delete mydb
|
|
502
|
-
spindb delete mydb --yes # Skip confirmation prompt
|
|
503
|
-
spindb delete mydb --force # Force stop if running
|
|
504
|
-
spindb delete mydb -fy # Both: force stop + skip confirmation
|
|
505
|
-
```
|
|
393
|
+
Databases run as **native processes**, and **data persists across restarts**. When you stop a container:
|
|
506
394
|
|
|
507
|
-
|
|
508
|
-
|
|
395
|
+
1. SpinDB sends a graceful shutdown signal
|
|
396
|
+
2. The database flushes pending writes to disk
|
|
397
|
+
3. Data remains in the `data/` directory
|
|
509
398
|
|
|
510
|
-
|
|
511
|
-
|--------|-------------|
|
|
512
|
-
| `--force`, `-f` | Force stop if container is running before deleting |
|
|
513
|
-
| `--yes`, `-y` | Skip confirmation prompt (for scripts/automation) |
|
|
514
|
-
| `--json`, `-j` | Output result as JSON |
|
|
399
|
+
**Your data is never deleted unless you explicitly run `spindb delete`.**
|
|
515
400
|
|
|
516
|
-
|
|
401
|
+
#### Durability by Engine
|
|
517
402
|
|
|
518
|
-
|
|
403
|
+
| Engine | Persistence Mechanism | Durability |
|
|
404
|
+
|--------|----------------------|------------|
|
|
405
|
+
| PostgreSQL | Write-Ahead Logging (WAL) | Committed transactions survive crashes |
|
|
406
|
+
| MySQL | InnoDB transaction logs | Committed transactions survive crashes |
|
|
407
|
+
| MariaDB | InnoDB transaction logs | Committed transactions survive crashes |
|
|
408
|
+
| SQLite | File-based transactions | Commits written immediately to disk |
|
|
409
|
+
| DuckDB | File-based transactions | Commits written immediately to disk |
|
|
410
|
+
| MongoDB | WiredTiger journaling | Writes journaled before acknowledged |
|
|
411
|
+
| Redis | RDB snapshots (periodic) | May lose ~60 seconds on unexpected crash |
|
|
412
|
+
| Valkey | RDB snapshots (periodic) | May lose ~60 seconds on unexpected crash |
|
|
413
|
+
| ClickHouse | MergeTree storage | Committed transactions survive crashes |
|
|
519
414
|
|
|
520
|
-
|
|
415
|
+
---
|
|
521
416
|
|
|
522
|
-
|
|
523
|
-
spindb connect mydb # Standard shell (psql/mysql)
|
|
524
|
-
spindb connect mydb --pgcli # Enhanced PostgreSQL shell
|
|
525
|
-
spindb connect mydb --mycli # Enhanced MySQL shell
|
|
526
|
-
spindb connect mydb --tui # Universal SQL client (usql)
|
|
527
|
-
```
|
|
417
|
+
## Engine-Specific Details
|
|
528
418
|
|
|
529
|
-
|
|
419
|
+
Each database engine has unique features and behaviors. See full documentation in [ENGINES.md](ENGINES.md).
|
|
530
420
|
|
|
531
|
-
|
|
532
|
-
spindb connect mydb --install-pgcli
|
|
533
|
-
spindb connect mydb --install-mycli
|
|
534
|
-
spindb connect mydb --install-tui
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
#### `run` - Execute SQL/scripts/commands
|
|
421
|
+
### PostgreSQL 🐘
|
|
538
422
|
|
|
539
423
|
```bash
|
|
540
|
-
|
|
541
|
-
spindb
|
|
542
|
-
spindb run mydb seed.sql --database my_app # Target specific database
|
|
424
|
+
# Create PostgreSQL database
|
|
425
|
+
spindb create myapp --engine postgresql --db-version 18
|
|
543
426
|
|
|
544
|
-
#
|
|
545
|
-
spindb
|
|
546
|
-
spindb
|
|
427
|
+
# Multiple versions side-by-side
|
|
428
|
+
spindb create legacy --engine postgresql --db-version 14
|
|
429
|
+
spindb create modern --engine postgresql --db-version 18
|
|
547
430
|
|
|
548
|
-
#
|
|
549
|
-
spindb
|
|
550
|
-
spindb
|
|
431
|
+
# Backup formats
|
|
432
|
+
spindb backup myapp --format sql # Plain SQL (.sql)
|
|
433
|
+
spindb backup myapp --format dump # Binary custom format (.dump)
|
|
551
434
|
```
|
|
552
435
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
spindb url mydb # postgresql://postgres@localhost:5432/mydb
|
|
557
|
-
spindb url mydb --copy # Copy to clipboard
|
|
558
|
-
spindb url mydb --json # JSON output with details
|
|
436
|
+
**Versions:** 15, 16, 17, 18
|
|
437
|
+
**Tools:** `psql`, `pg_dump`, `pg_restore` (included)
|
|
438
|
+
**Enhanced client:** `pgcli` (auto-completion, syntax highlighting)
|
|
559
439
|
|
|
560
|
-
|
|
561
|
-
export DATABASE_URL=$(spindb url mydb)
|
|
562
|
-
psql $(spindb url mydb)
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
#### `backup` - Create a backup
|
|
566
|
-
|
|
567
|
-
```bash
|
|
568
|
-
spindb backup mydb # Auto-generated filename
|
|
569
|
-
spindb backup mydb --name my-backup # Custom name
|
|
570
|
-
spindb backup mydb --output ./backups/ # Custom directory
|
|
571
|
-
spindb backup mydb --database my_app # Backup specific database
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
Backup formats (vary by engine):
|
|
440
|
+
### MySQL 🐬 & MariaDB 🦭
|
|
575
441
|
|
|
576
442
|
```bash
|
|
577
|
-
|
|
578
|
-
spindb
|
|
443
|
+
# MySQL
|
|
444
|
+
spindb create shop --engine mysql --db-version 9
|
|
445
|
+
spindb connect shop --mycli
|
|
579
446
|
|
|
580
|
-
#
|
|
581
|
-
spindb
|
|
582
|
-
spindb backup mydb --dump
|
|
447
|
+
# MariaDB (MySQL-compatible)
|
|
448
|
+
spindb create store --engine mariadb --db-version 11.8
|
|
583
449
|
```
|
|
584
450
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
- MySQL: `.sql` (plain SQL) / `.sql.gz` (compressed SQL)
|
|
589
|
-
- SQLite: `.sql` (plain SQL) / `.sqlite` (binary copy)
|
|
590
|
-
- MongoDB: `.bson` (BSON dump) / `.archive` (compressed archive)
|
|
591
|
-
- Redis: `.redis` (text commands) / `.rdb` (RDB snapshot)
|
|
592
|
-
- Valkey: `.valkey` (text commands) / `.rdb` (RDB snapshot)
|
|
451
|
+
**MySQL versions:** 8.0, 8.4, 9
|
|
452
|
+
**MariaDB versions:** 10.11, 11.4, 11.8
|
|
453
|
+
**Tools:** `mysql`, `mysqldump`, `mysqladmin` (included)
|
|
593
454
|
|
|
594
|
-
|
|
595
|
-
<summary>All options</summary>
|
|
596
|
-
|
|
597
|
-
| Option | Description |
|
|
598
|
-
|--------|-------------|
|
|
599
|
-
| `--database`, `-d` | Database to backup (defaults to primary) |
|
|
600
|
-
| `--name`, `-n` | Custom backup filename (without extension) |
|
|
601
|
-
| `--output`, `-o` | Output directory (defaults to current directory) |
|
|
602
|
-
| `--format` | Output format: `sql` or `dump` |
|
|
603
|
-
| `--sql` | Shorthand for `--format sql` |
|
|
604
|
-
| `--dump` | Shorthand for `--format dump` |
|
|
605
|
-
| `--json`, `-j` | Output result as JSON |
|
|
606
|
-
|
|
607
|
-
</details>
|
|
608
|
-
|
|
609
|
-
#### `backups` - List backup files
|
|
455
|
+
### MongoDB 🍃
|
|
610
456
|
|
|
611
457
|
```bash
|
|
612
|
-
|
|
613
|
-
spindb
|
|
614
|
-
spindb backups --all # Include ~/.spindb/backups
|
|
615
|
-
spindb backups --limit 50 # Show more results
|
|
616
|
-
spindb backups --json # JSON output
|
|
617
|
-
```
|
|
458
|
+
# Create MongoDB database
|
|
459
|
+
spindb create logs --engine mongodb --db-version 8.0
|
|
618
460
|
|
|
619
|
-
|
|
620
|
-
|
|
461
|
+
# JavaScript queries (not SQL)
|
|
462
|
+
spindb run logs -c "db.users.insertOne({name: 'Alice'})"
|
|
463
|
+
spindb run logs -c "db.users.find().pretty()"
|
|
464
|
+
spindb run logs seed.js
|
|
621
465
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
| `--limit`, `-n` | Limit number of results (default: 20) |
|
|
626
|
-
| `--json`, `-j` | Output as JSON |
|
|
466
|
+
# Connect with mongosh
|
|
467
|
+
spindb connect logs
|
|
468
|
+
```
|
|
627
469
|
|
|
628
|
-
|
|
470
|
+
**Versions:** 7.0, 8.0, 8.2
|
|
471
|
+
**Query language:** JavaScript (via `mongosh`)
|
|
472
|
+
**Tools:** `mongod`, `mongosh`, `mongodump`, `mongorestore` (included)
|
|
629
473
|
|
|
630
|
-
|
|
474
|
+
### Redis 🔴 & Valkey 🔷
|
|
631
475
|
|
|
632
476
|
```bash
|
|
633
|
-
|
|
634
|
-
spindb
|
|
635
|
-
spindb restore mydb --from-url "postgresql://user:pass@host/db"
|
|
636
|
-
```
|
|
477
|
+
# Redis
|
|
478
|
+
spindb create cache --engine redis --db-version 8
|
|
637
479
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
```bash
|
|
641
|
-
# Restore into a NEW database without affecting existing data
|
|
642
|
-
spindb restore mydb prod-backup.dump --database prod_copy
|
|
480
|
+
# Valkey (Redis fork with BSD-3 license)
|
|
481
|
+
spindb create sessions --engine valkey --db-version 9
|
|
643
482
|
|
|
644
|
-
#
|
|
645
|
-
spindb
|
|
483
|
+
# Redis commands
|
|
484
|
+
spindb run cache -c "SET mykey myvalue"
|
|
485
|
+
spindb run cache -c "GET mykey"
|
|
646
486
|
|
|
647
|
-
#
|
|
648
|
-
spindb
|
|
487
|
+
# Enhanced shell
|
|
488
|
+
spindb connect cache --iredis
|
|
649
489
|
```
|
|
650
490
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
| `--database`, `-d` | Target database name (creates new if doesn't exist) |
|
|
657
|
-
| `--from-url` | Pull data from a remote database connection string |
|
|
658
|
-
| `--force`, `-f` | Overwrite existing database without confirmation |
|
|
659
|
-
| `--json`, `-j` | Output result as JSON |
|
|
660
|
-
|
|
661
|
-
</details>
|
|
662
|
-
|
|
663
|
-
#### Backup & Restore Format Reference
|
|
664
|
-
|
|
665
|
-
Each engine has specific backup formats and restore behaviors:
|
|
666
|
-
|
|
667
|
-
<details>
|
|
668
|
-
<summary>PostgreSQL</summary>
|
|
669
|
-
|
|
670
|
-
| Format | Extension | Tool | Notes |
|
|
671
|
-
|--------|-----------|------|-------|
|
|
672
|
-
| SQL | `.sql` | pg_dump | Plain text SQL, human-readable |
|
|
673
|
-
| Custom | `.dump` | pg_dump -Fc | Compressed, supports parallel restore |
|
|
674
|
-
|
|
675
|
-
**Restore behavior:** Creates new database or replaces existing. Uses `pg_restore` for `.dump`, `psql` for `.sql`.
|
|
676
|
-
|
|
677
|
-
</details>
|
|
678
|
-
|
|
679
|
-
<details>
|
|
680
|
-
<summary>MariaDB</summary>
|
|
681
|
-
|
|
682
|
-
| Format | Extension | Tool | Notes |
|
|
683
|
-
|--------|-----------|------|-------|
|
|
684
|
-
| SQL | `.sql` | mariadb-dump | Plain text SQL |
|
|
685
|
-
| Compressed | `.sql.gz` | mariadb-dump + gzip | Gzip compressed SQL |
|
|
686
|
-
|
|
687
|
-
**Restore behavior:** Creates new database or replaces existing. Pipes to `mariadb` client.
|
|
688
|
-
|
|
689
|
-
</details>
|
|
690
|
-
|
|
691
|
-
<details>
|
|
692
|
-
<summary>MySQL</summary>
|
|
693
|
-
|
|
694
|
-
| Format | Extension | Tool | Notes |
|
|
695
|
-
|--------|-----------|------|-------|
|
|
696
|
-
| SQL | `.sql` | mysqldump | Plain text SQL |
|
|
697
|
-
| Compressed | `.sql.gz` | mysqldump + gzip | Gzip compressed SQL |
|
|
491
|
+
**Redis versions:** 7, 8
|
|
492
|
+
**Valkey versions:** 8, 9
|
|
493
|
+
**Query language:** Redis commands
|
|
494
|
+
**Databases:** Numbered 0-15 (not named)
|
|
495
|
+
**Tools:** `redis-cli`, `redis-server` / `valkey-cli`, `valkey-server` (included)
|
|
698
496
|
|
|
699
|
-
|
|
497
|
+
### SQLite 🪶 & DuckDB 🦆
|
|
700
498
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
| Format | Extension | Tool | Notes |
|
|
707
|
-
|--------|-----------|------|-------|
|
|
708
|
-
| SQL | `.sql` | .dump | Plain text SQL |
|
|
709
|
-
| Binary | `.sqlite` | File copy | Exact copy of database file |
|
|
710
|
-
|
|
711
|
-
**Restore behavior:** Creates new file or replaces existing.
|
|
712
|
-
|
|
713
|
-
</details>
|
|
714
|
-
|
|
715
|
-
<details>
|
|
716
|
-
<summary>MongoDB</summary>
|
|
717
|
-
|
|
718
|
-
| Format | Extension | Tool | Notes |
|
|
719
|
-
|--------|-----------|------|-------|
|
|
720
|
-
| BSON | `.bson` | mongodump | Binary JSON per collection |
|
|
721
|
-
| Archive | `.archive` | mongodump --archive | Single compressed file |
|
|
722
|
-
|
|
723
|
-
**Restore behavior:** Creates new database or replaces existing. Uses `mongorestore`.
|
|
724
|
-
|
|
725
|
-
</details>
|
|
726
|
-
|
|
727
|
-
<details>
|
|
728
|
-
<summary>Redis</summary>
|
|
729
|
-
|
|
730
|
-
| Format | Extension | Tool | Notes |
|
|
731
|
-
|--------|-----------|------|-------|
|
|
732
|
-
| RDB | `.rdb` | BGSAVE | Binary snapshot, requires restart |
|
|
733
|
-
| Text | `.redis` | Custom | Human-readable Redis commands |
|
|
734
|
-
|
|
735
|
-
**Text format detection:** Files are detected as Redis text commands if they contain valid Redis commands (SET, HSET, DEL, etc.), regardless of file extension. This allows restoring files like `users.txt` or `data` without renaming.
|
|
499
|
+
```bash
|
|
500
|
+
# SQLite - embedded relational database
|
|
501
|
+
spindb create app --engine sqlite --path ./data/app.sqlite
|
|
502
|
+
spindb connect app
|
|
736
503
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
- **Merge:** Adds/updates keys, keeps existing keys not in backup
|
|
504
|
+
# DuckDB - embedded analytics database (OLAP)
|
|
505
|
+
spindb create analytics --engine duckdb --path ./data/warehouse.duckdb
|
|
506
|
+
spindb connect analytics
|
|
507
|
+
```
|
|
742
508
|
|
|
743
|
-
**
|
|
509
|
+
**No server process** - File-based databases stored in your project directories.
|
|
510
|
+
**No start/stop needed** - Always "running" (embedded).
|
|
511
|
+
**SQLite tools:** `sqlite3`, `sqldiff`, `sqlite3_analyzer` (included)
|
|
512
|
+
**DuckDB tools:** `duckdb` (included)
|
|
744
513
|
|
|
745
|
-
|
|
514
|
+
### ClickHouse 🏠
|
|
746
515
|
|
|
747
|
-
|
|
748
|
-
|
|
516
|
+
```bash
|
|
517
|
+
# Create ClickHouse database (columnar OLAP)
|
|
518
|
+
spindb create warehouse --engine clickhouse
|
|
749
519
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
520
|
+
# SQL with ClickHouse extensions
|
|
521
|
+
spindb run warehouse -c "CREATE TABLE events (timestamp DateTime, user_id UInt64) ENGINE = MergeTree() ORDER BY timestamp"
|
|
522
|
+
spindb run warehouse -c "SELECT * FROM system.tables"
|
|
523
|
+
```
|
|
754
524
|
|
|
755
|
-
**
|
|
525
|
+
**Version:** 25.12 (YY.MM versioning)
|
|
526
|
+
**Platforms:** macOS, Linux (no Windows support)
|
|
527
|
+
**Ports:** 9000 (native TCP), 8123 (HTTP)
|
|
528
|
+
**Tools:** `clickhouse-client`, `clickhouse-server` (included)
|
|
756
529
|
|
|
757
|
-
|
|
758
|
-
- **RDB (`.rdb`):** Requires stopping Valkey, copies file to data directory, restart loads data
|
|
759
|
-
- **Text (`.valkey`):** Pipes commands to running Valkey instance. Prompts for:
|
|
760
|
-
- **Replace all:** Runs `FLUSHDB` first (clean slate)
|
|
761
|
-
- **Merge:** Adds/updates keys, keeps existing keys not in backup
|
|
530
|
+
---
|
|
762
531
|
|
|
763
|
-
|
|
532
|
+
## Enhanced CLI Tools
|
|
764
533
|
|
|
765
|
-
|
|
534
|
+
SpinDB supports enhanced database shells with auto-completion, syntax highlighting, and better formatting:
|
|
766
535
|
|
|
767
|
-
|
|
536
|
+
| Engine | Standard Client | Enhanced Client | Universal Client |
|
|
537
|
+
|--------|----------------|-----------------|------------------|
|
|
538
|
+
| PostgreSQL | `psql` | `pgcli` | `usql` |
|
|
539
|
+
| MySQL | `mysql` | `mycli` | `usql` |
|
|
540
|
+
| MariaDB | `mariadb` | `mycli` | `usql` |
|
|
541
|
+
| SQLite | `sqlite3` | `litecli` | `usql` |
|
|
542
|
+
| DuckDB | `duckdb` | - | `usql` |
|
|
543
|
+
| MongoDB | `mongosh` | - | - |
|
|
544
|
+
| Redis | `redis-cli` | `iredis` | - |
|
|
545
|
+
| Valkey | `valkey-cli` | `iredis` (compatible) | - |
|
|
546
|
+
| ClickHouse | `clickhouse-client` | - | `usql` |
|
|
768
547
|
|
|
769
|
-
|
|
548
|
+
Install and use in one command:
|
|
770
549
|
|
|
771
550
|
```bash
|
|
772
|
-
spindb
|
|
773
|
-
spindb
|
|
551
|
+
spindb connect mydb --install-pgcli
|
|
552
|
+
spindb connect mydb --install-mycli
|
|
553
|
+
spindb connect mydb --install-tui # usql (universal)
|
|
774
554
|
```
|
|
775
555
|
|
|
776
|
-
|
|
556
|
+
---
|
|
777
557
|
|
|
778
|
-
|
|
779
|
-
spindb info # All containers
|
|
780
|
-
spindb info mydb # Specific container
|
|
781
|
-
spindb info mydb --json
|
|
782
|
-
```
|
|
558
|
+
## Backup & Restore
|
|
783
559
|
|
|
784
|
-
|
|
560
|
+
Every engine supports backup and restore with engine-specific formats:
|
|
785
561
|
|
|
786
|
-
|
|
787
|
-
spindb stop source-db # Source must be stopped
|
|
788
|
-
spindb clone source-db new-db
|
|
789
|
-
spindb start new-db
|
|
790
|
-
```
|
|
562
|
+
### PostgreSQL
|
|
791
563
|
|
|
792
|
-
|
|
564
|
+
| Format | Extension | Tool | Use Case |
|
|
565
|
+
|--------|-----------|------|----------|
|
|
566
|
+
| SQL | `.sql` | pg_dump | Human-readable, portable |
|
|
567
|
+
| Custom | `.dump` | pg_dump -Fc | Compressed, faster restore |
|
|
793
568
|
|
|
794
569
|
```bash
|
|
795
|
-
spindb
|
|
796
|
-
spindb
|
|
797
|
-
spindb
|
|
798
|
-
spindb edit mydb --set-config max_connections=300 # PostgreSQL config
|
|
799
|
-
spindb edit mydb # Interactive mode
|
|
570
|
+
spindb backup mydb --sql # Plain SQL
|
|
571
|
+
spindb backup mydb --dump # Binary custom format
|
|
572
|
+
spindb restore mydb backup.dump
|
|
800
573
|
```
|
|
801
574
|
|
|
802
|
-
|
|
575
|
+
### MySQL & MariaDB
|
|
576
|
+
|
|
577
|
+
| Format | Extension | Tool | Use Case |
|
|
578
|
+
|--------|-----------|------|----------|
|
|
579
|
+
| SQL | `.sql` | mysqldump / mariadb-dump | Human-readable |
|
|
580
|
+
| Compressed | `.sql.gz` | mysqldump + gzip | Smaller file size |
|
|
803
581
|
|
|
804
582
|
```bash
|
|
805
|
-
spindb
|
|
806
|
-
spindb
|
|
807
|
-
spindb logs mydb -n 50 # Last 50 lines
|
|
808
|
-
spindb logs mydb --editor # Open in $EDITOR
|
|
583
|
+
spindb backup mydb --sql # Plain SQL
|
|
584
|
+
spindb backup mydb --dump # Compressed SQL
|
|
809
585
|
```
|
|
810
586
|
|
|
811
|
-
###
|
|
587
|
+
### MongoDB
|
|
812
588
|
|
|
813
|
-
|
|
589
|
+
| Format | Extension | Tool | Use Case |
|
|
590
|
+
|--------|-----------|------|----------|
|
|
591
|
+
| BSON | `.bson` | mongodump | Binary, preserves all types |
|
|
592
|
+
| Archive | `.archive` | mongodump --archive | Single compressed file |
|
|
814
593
|
|
|
815
594
|
```bash
|
|
816
|
-
spindb
|
|
817
|
-
spindb
|
|
818
|
-
spindb engines supported # List all supported engines
|
|
819
|
-
spindb engines supported --json # Full engine config as JSON
|
|
820
|
-
spindb engines supported --all # Include pending/planned engines
|
|
821
|
-
spindb engines delete postgresql 16 # Delete a version (frees ~45MB)
|
|
595
|
+
spindb backup mydb # BSON directory
|
|
596
|
+
spindb backup mydb --format archive # Single .archive file
|
|
822
597
|
```
|
|
823
598
|
|
|
824
|
-
|
|
599
|
+
### Redis & Valkey
|
|
825
600
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
🐘 postgresql 17.7 darwin-arm64 45.2 MB
|
|
831
|
-
🐬 mysql 9.0.1 darwin-arm64 150.0 MB
|
|
832
|
-
🪶 sqlite 3.51.2 darwin-arm64 5.0 MB
|
|
833
|
-
────────────────────────────────────────────────────────
|
|
834
|
-
|
|
835
|
-
PostgreSQL: 2 version(s), 90.0 MB
|
|
836
|
-
MySQL: 1 version(s), 150.0 MB
|
|
837
|
-
SQLite: 1 version(s), 5.0 MB
|
|
838
|
-
```
|
|
601
|
+
| Format | Extension | Tool | Use Case |
|
|
602
|
+
|--------|-----------|------|----------|
|
|
603
|
+
| RDB | `.rdb` | BGSAVE | Binary snapshot, requires restart |
|
|
604
|
+
| Text | `.redis` / `.valkey` | Custom | Human-readable commands |
|
|
839
605
|
|
|
840
|
-
|
|
606
|
+
```bash
|
|
607
|
+
spindb backup mydb --dump # RDB snapshot
|
|
608
|
+
spindb backup mydb --sql # Text commands
|
|
841
609
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
🐬 mysql
|
|
845
|
-
🦭 mariadb
|
|
846
|
-
🪶 sqlite
|
|
847
|
-
🍃 mongodb
|
|
848
|
-
🔴 redis
|
|
849
|
-
🔷 valkey
|
|
610
|
+
# Restore with merge or replace strategy
|
|
611
|
+
spindb restore mydb backup.redis # Prompts: Replace all / Merge
|
|
850
612
|
```
|
|
851
613
|
|
|
852
|
-
|
|
614
|
+
### SQLite & DuckDB
|
|
853
615
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
spindb deps install --engine mysql # Install for specific engine
|
|
859
|
-
```
|
|
860
|
-
|
|
861
|
-
#### `config` - Configuration
|
|
616
|
+
| Format | Extension | Tool | Use Case |
|
|
617
|
+
|--------|-----------|------|----------|
|
|
618
|
+
| SQL | `.sql` | .dump / duckdb | Human-readable |
|
|
619
|
+
| Binary | `.sqlite` / `.duckdb` | File copy | Exact database copy |
|
|
862
620
|
|
|
863
621
|
```bash
|
|
864
|
-
spindb
|
|
865
|
-
spindb
|
|
866
|
-
spindb config update-check on # Enable update notifications
|
|
867
|
-
spindb config update-check off # Disable update notifications
|
|
622
|
+
spindb backup mydb --sql # SQL dump
|
|
623
|
+
spindb backup mydb --dump # Binary copy
|
|
868
624
|
```
|
|
869
625
|
|
|
870
|
-
|
|
626
|
+
### ClickHouse
|
|
871
627
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
#### `self-update` - Update SpinDB
|
|
628
|
+
| Format | Extension | Tool | Use Case |
|
|
629
|
+
|--------|-----------|------|----------|
|
|
630
|
+
| SQL | `.sql` | clickhouse-client | Plain SQL dump |
|
|
631
|
+
| Native | `.clickhouse` | clickhouse-backup | Native format (future) |
|
|
878
632
|
|
|
879
633
|
```bash
|
|
880
|
-
spindb
|
|
634
|
+
spindb backup mydb --sql # SQL dump
|
|
881
635
|
```
|
|
882
636
|
|
|
883
|
-
|
|
637
|
+
---
|
|
884
638
|
|
|
885
|
-
|
|
886
|
-
spindb doctor # Interactive health check
|
|
887
|
-
spindb doctor --json # JSON output for scripting
|
|
888
|
-
```
|
|
639
|
+
## Advanced Features
|
|
889
640
|
|
|
890
|
-
|
|
891
|
-
- Configuration file validity and binary cache freshness
|
|
892
|
-
- Container status across all engines
|
|
893
|
-
- SQLite registry for orphaned entries (files deleted outside SpinDB)
|
|
894
|
-
- Database tool availability
|
|
641
|
+
### Clone Databases
|
|
895
642
|
|
|
896
|
-
|
|
643
|
+
Create exact copies of existing databases:
|
|
897
644
|
|
|
645
|
+
```bash
|
|
646
|
+
# Clone local database (must be stopped)
|
|
647
|
+
spindb stop production
|
|
648
|
+
spindb clone production staging
|
|
649
|
+
spindb start production
|
|
650
|
+
spindb start staging
|
|
898
651
|
```
|
|
899
|
-
SpinDB Health Check
|
|
900
|
-
═══════════════════
|
|
901
652
|
|
|
902
|
-
|
|
903
|
-
└─ Configuration valid, 12 tools cached
|
|
653
|
+
### Restore from Remote
|
|
904
654
|
|
|
905
|
-
|
|
906
|
-
└─ 4 container(s)
|
|
907
|
-
postgresql: 2 running, 0 stopped
|
|
908
|
-
mysql: 0 running, 1 stopped
|
|
909
|
-
sqlite: 1 exist, 0 missing
|
|
655
|
+
Pull production data into local databases:
|
|
910
656
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
657
|
+
```bash
|
|
658
|
+
# Create new database from remote
|
|
659
|
+
spindb create prod-copy --from "postgresql://user:pass@prod-host:5432/production"
|
|
914
660
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
Skip (do nothing)
|
|
661
|
+
# Or restore into existing database
|
|
662
|
+
spindb restore mydb --from-url "postgresql://user:pass@prod-host:5432/production"
|
|
918
663
|
```
|
|
919
664
|
|
|
920
|
-
|
|
665
|
+
### Multi-Version Support
|
|
921
666
|
|
|
922
|
-
|
|
667
|
+
Run different versions of the same database simultaneously:
|
|
923
668
|
|
|
924
|
-
|
|
669
|
+
```bash
|
|
670
|
+
# PostgreSQL 14 for legacy app
|
|
671
|
+
spindb create legacy-api --engine postgresql --db-version 14 --port 5432
|
|
925
672
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
| PostgreSQL | `psql` | `pgcli` | `usql` |
|
|
929
|
-
| MariaDB | `mariadb` | `mycli` | `usql` |
|
|
930
|
-
| MySQL | `mysql` | `mycli` | `usql` |
|
|
931
|
-
| SQLite | `sqlite3` | `litecli` | `usql` |
|
|
932
|
-
| MongoDB | `mongosh` | - | `usql` |
|
|
933
|
-
| Redis | `redis-cli` | `iredis` | - |
|
|
934
|
-
| Valkey | `valkey-cli` | `iredis` | - |
|
|
673
|
+
# PostgreSQL 18 for new app
|
|
674
|
+
spindb create modern-api --engine postgresql --db-version 18 --port 5433
|
|
935
675
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
-
|
|
676
|
+
# Both running at the same time
|
|
677
|
+
spindb list
|
|
678
|
+
# NAME ENGINE VERSION PORT STATUS
|
|
679
|
+
# legacy-api postgresql 14 5432 running
|
|
680
|
+
# modern-api postgresql 18 5433 running
|
|
681
|
+
```
|
|
941
682
|
|
|
942
|
-
|
|
683
|
+
### Custom Ports
|
|
943
684
|
|
|
944
|
-
|
|
685
|
+
SpinDB auto-assigns ports, but you can override:
|
|
945
686
|
|
|
946
687
|
```bash
|
|
947
|
-
spindb
|
|
948
|
-
spindb
|
|
949
|
-
spindb connect mydb --install-tui # usql
|
|
688
|
+
spindb create mydb --port 5433
|
|
689
|
+
spindb edit mydb --port 5434 # Change later
|
|
950
690
|
```
|
|
951
691
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
## Architecture
|
|
955
|
-
|
|
956
|
-
### How It Works
|
|
957
|
-
|
|
958
|
-
SpinDB uses the term "container" loosely—there's no Docker involved. When you create a container, SpinDB:
|
|
692
|
+
### SQLite & DuckDB Registry
|
|
959
693
|
|
|
960
|
-
|
|
961
|
-
2. Creates an isolated data directory at `~/.spindb/containers/{engine}/{name}/`
|
|
962
|
-
3. Runs the database as a native process on your machine
|
|
694
|
+
File-based databases can be registered for easy access:
|
|
963
695
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
- A log file (`postgres.log`, `mysql.log`, or `mongodb.log`)
|
|
696
|
+
```bash
|
|
697
|
+
# Create and register
|
|
698
|
+
spindb create mydb --engine sqlite --path ./data/app.sqlite
|
|
968
699
|
|
|
969
|
-
|
|
700
|
+
# Attach existing database
|
|
701
|
+
spindb attach ./existing/data.sqlite --name legacy-db
|
|
970
702
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
```
|
|
974
|
-
~/.spindb/
|
|
975
|
-
├── bin/ # Downloaded server binaries
|
|
976
|
-
│ └── postgresql-18.1.0-darwin-arm64/ # ~45 MB per version
|
|
977
|
-
├── containers/
|
|
978
|
-
│ ├── postgresql/
|
|
979
|
-
│ │ └── mydb/
|
|
980
|
-
│ │ ├── container.json # Configuration
|
|
981
|
-
│ │ ├── data/ # Database files
|
|
982
|
-
│ │ └── postgres.log # Server logs
|
|
983
|
-
│ └── mysql/
|
|
984
|
-
│ └── mydb/
|
|
985
|
-
│ ├── container.json
|
|
986
|
-
│ ├── data/
|
|
987
|
-
│ └── mysql.log
|
|
988
|
-
├── logs/ # Error logs
|
|
989
|
-
└── config.json # Tool paths cache
|
|
990
|
-
|
|
991
|
-
# SQLite databases are stored in project directories, not ~/.spindb/
|
|
992
|
-
./myproject/
|
|
993
|
-
└── mydb.sqlite # Created with: spindb create mydb -e sqlite
|
|
703
|
+
# Detach (removes from registry, keeps file)
|
|
704
|
+
spindb detach legacy-db
|
|
994
705
|
```
|
|
995
706
|
|
|
996
|
-
### Data Persistence
|
|
997
|
-
|
|
998
|
-
SpinDB runs databases as **native processes** on your machine. When you start a container:
|
|
999
|
-
|
|
1000
|
-
1. SpinDB launches the database server binary (`pg_ctl start` or `mysqld`)
|
|
1001
|
-
2. The server binds to `127.0.0.1` on your configured port
|
|
1002
|
-
3. A PID file tracks the running process
|
|
1003
|
-
4. Logs are written to the container's log file
|
|
1004
|
-
|
|
1005
|
-
When you stop a container:
|
|
1006
|
-
|
|
1007
|
-
1. SpinDB sends a graceful shutdown signal
|
|
1008
|
-
2. The database flushes pending writes to disk
|
|
1009
|
-
3. The PID file is removed
|
|
1010
|
-
4. Your data remains in the `data/` directory
|
|
1011
|
-
|
|
1012
|
-
**Your data is never deleted unless you explicitly delete the container.**
|
|
1013
|
-
|
|
1014
|
-
#### Persistence by Engine
|
|
1015
|
-
|
|
1016
|
-
Each database engine has its own persistence mechanism:
|
|
1017
|
-
|
|
1018
|
-
| Engine | Mechanism | Durability |
|
|
1019
|
-
|--------|-----------|------------|
|
|
1020
|
-
| PostgreSQL | Write-Ahead Logging (WAL) | Every commit is immediately durable |
|
|
1021
|
-
| MariaDB | InnoDB transaction logs | Every commit is immediately durable |
|
|
1022
|
-
| MySQL | InnoDB transaction logs | Every commit is immediately durable |
|
|
1023
|
-
| SQLite | File-based transactions | Every commit is immediately durable |
|
|
1024
|
-
| MongoDB | WiredTiger with journaling | Writes journaled before acknowledged |
|
|
1025
|
-
| Redis | RDB snapshots | Periodic snapshots (see below) |
|
|
1026
|
-
|
|
1027
|
-
**PostgreSQL, MariaDB, MySQL, MongoDB:** These engines use transaction logs or journaling. Every committed write is guaranteed to survive a crash or unexpected shutdown.
|
|
1028
|
-
|
|
1029
|
-
**SQLite:** As a file-based database, SQLite writes directly to disk on each commit. No server process means no risk of losing in-flight data.
|
|
1030
|
-
|
|
1031
|
-
**Redis:** SpinDB configures Redis with RDB (Redis Database) snapshots:
|
|
1032
|
-
- Save after 900 seconds if at least 1 key changed
|
|
1033
|
-
- Save after 300 seconds if at least 10 keys changed
|
|
1034
|
-
- Save after 60 seconds if at least 10,000 keys changed
|
|
1035
|
-
|
|
1036
|
-
This means Redis may lose up to ~60 seconds of writes on an unexpected crash. For local development, this trade-off (speed over strict durability) is typically acceptable. If you need stronger guarantees, use `spindb backup` before stopping work.
|
|
1037
|
-
|
|
1038
|
-
### Binary Sources
|
|
1039
|
-
|
|
1040
|
-
**PostgreSQL:** Server binaries are downloaded automatically:
|
|
1041
|
-
- **macOS/Linux:** From [hostdb](https://github.com/robertjbass/hostdb) on GitHub Releases
|
|
1042
|
-
- **Windows:** From [EnterpriseDB (EDB)](https://www.enterprisedb.com/download-postgresql-binaries)
|
|
1043
|
-
|
|
1044
|
-
**MariaDB, MySQL, MongoDB, Redis, Valkey:** Server binaries are downloaded automatically from [hostdb](https://github.com/robertjbass/hostdb) on GitHub Releases for all platforms.
|
|
1045
|
-
|
|
1046
|
-
### Why Precompiled Binaries?
|
|
1047
|
-
|
|
1048
|
-
The [hostdb](https://github.com/robertjbass/hostdb) project provides pre-compiled, portable database binaries:
|
|
1049
|
-
|
|
1050
|
-
- Cross-platform (macOS Intel/ARM, Linux x64/ARM, Windows x64)
|
|
1051
|
-
- Hosted on GitHub Releases (highly reliable CDN)
|
|
1052
|
-
- ~45-200 MB per version depending on engine
|
|
1053
|
-
- Actively maintained with new database releases
|
|
1054
|
-
|
|
1055
|
-
This makes multi-version support trivial: need PostgreSQL 14 for a legacy project and 18 for a new one? Need MongoDB 7.0 and 8.0? Redis 7 and 8? SpinDB downloads them all, and they run side-by-side without conflicts.
|
|
1056
|
-
|
|
1057
|
-
---
|
|
1058
|
-
|
|
1059
|
-
## Limitations
|
|
1060
|
-
|
|
1061
|
-
- **Local only** - Databases bind to `127.0.0.1`; remote connections planned for v1.1
|
|
1062
|
-
- **Redis remote dump not supported** - Redis doesn't support creating containers from remote connection strings. Use backup/restore for data migration.
|
|
1063
|
-
|
|
1064
707
|
---
|
|
1065
708
|
|
|
1066
709
|
## Roadmap
|
|
1067
710
|
|
|
1068
|
-
See [TODO.md](TODO.md) for the
|
|
711
|
+
See [TODO.md](TODO.md) for the complete roadmap.
|
|
1069
712
|
|
|
1070
713
|
### v1.1 - Remote Connections & Secrets
|
|
1071
|
-
-
|
|
714
|
+
- Direct remote database connections (`spindb connect --remote`)
|
|
1072
715
|
- Environment variable support in connection strings
|
|
1073
|
-
- Secrets management
|
|
716
|
+
- Secrets management with macOS Keychain integration
|
|
1074
717
|
|
|
1075
718
|
### v1.2 - Additional Engines
|
|
1076
|
-
- CockroachDB
|
|
719
|
+
- **CockroachDB** - Distributed PostgreSQL-compatible database
|
|
720
|
+
- **FerretDB** - MongoDB-compatible database built on PostgreSQL
|
|
1077
721
|
|
|
1078
722
|
### v1.3 - Advanced Features
|
|
1079
|
-
- Container templates
|
|
1080
|
-
- Scheduled backups
|
|
1081
|
-
- Import from Docker
|
|
1082
|
-
|
|
1083
|
-
### Future Infrastructure
|
|
1084
|
-
- **hostdb npm package**: Available database versions will be published as an npm package from [hostdb](https://github.com/robertjbass/hostdb) and imported into SpinDB, eliminating the need to manually sync version-maps.ts with releases.json
|
|
1085
|
-
- **pnpm 10 upgrade**: Currently pinned to pnpm 9.x (`packageManager` in package.json and Docker). Consider upgrading to pnpm 10.x when stable—requires updating package.json, Dockerfile, regenerating pnpm-lock.yaml, and testing for lockfile format changes
|
|
723
|
+
- Container templates for common configurations
|
|
724
|
+
- Scheduled automated backups
|
|
725
|
+
- Import databases from Docker containers
|
|
1086
726
|
|
|
1087
|
-
###
|
|
727
|
+
### Future Engines Under Consideration
|
|
1088
728
|
|
|
1089
|
-
|
|
729
|
+
The following engines may be added based on community interest:
|
|
1090
730
|
|
|
1091
731
|
| Engine | Type | Notes |
|
|
1092
732
|
|--------|------|-------|
|
|
1093
|
-
| **
|
|
1094
|
-
| **
|
|
1095
|
-
| **
|
|
1096
|
-
| **
|
|
1097
|
-
| **Neo4j** | Graph database |
|
|
1098
|
-
|
|
733
|
+
| **libSQL** | Embedded relational | SQLite fork with replication |
|
|
734
|
+
| **Meilisearch** | Search engine | Developer-friendly full-text search |
|
|
735
|
+
| **OpenSearch** | Search engine | Elasticsearch alternative |
|
|
736
|
+
| **InfluxDB** | Time-series | Metrics and IoT data |
|
|
737
|
+
| **Neo4j** | Graph database | Relationships and network data |
|
|
738
|
+
|
|
739
|
+
---
|
|
740
|
+
|
|
741
|
+
## Limitations
|
|
742
|
+
|
|
743
|
+
- **Local only** - Databases bind to `127.0.0.1`. Remote connection support planned for v1.1.
|
|
744
|
+
- **ClickHouse Windows** - Not supported (hostdb doesn't build for Windows).
|
|
745
|
+
- **Redis/Valkey remote dump** - Cannot create containers directly from remote connection strings. Use backup/restore workflow instead.
|
|
1099
746
|
|
|
1100
747
|
---
|
|
1101
748
|
|
|
1102
749
|
## Troubleshooting
|
|
1103
750
|
|
|
1104
|
-
### Port
|
|
751
|
+
### Port Already in Use
|
|
1105
752
|
|
|
1106
|
-
SpinDB automatically finds
|
|
753
|
+
SpinDB automatically finds available ports, but you can specify:
|
|
1107
754
|
|
|
1108
755
|
```bash
|
|
1109
756
|
spindb create mydb --port 5433
|
|
1110
757
|
```
|
|
1111
758
|
|
|
1112
|
-
###
|
|
759
|
+
### Container Won't Start
|
|
1113
760
|
|
|
1114
|
-
|
|
761
|
+
Check the logs:
|
|
1115
762
|
|
|
1116
763
|
```bash
|
|
1117
|
-
spindb
|
|
764
|
+
spindb logs mydb
|
|
1118
765
|
# or
|
|
1119
|
-
spindb
|
|
766
|
+
cat ~/.spindb/containers/postgresql/mydb/postgres.log
|
|
1120
767
|
```
|
|
1121
768
|
|
|
1122
|
-
###
|
|
769
|
+
### Client Tool Not Found
|
|
1123
770
|
|
|
1124
|
-
|
|
771
|
+
Install dependencies:
|
|
1125
772
|
|
|
1126
773
|
```bash
|
|
1127
|
-
spindb
|
|
1128
|
-
|
|
1129
|
-
cat ~/.spindb/containers/postgresql/mydb/postgres.log
|
|
774
|
+
spindb deps install
|
|
775
|
+
spindb deps check
|
|
1130
776
|
```
|
|
1131
777
|
|
|
1132
|
-
###
|
|
778
|
+
### Binary Download Fails
|
|
779
|
+
|
|
780
|
+
SpinDB downloads from [hostdb GitHub Releases](https://github.com/robertjbass/hostdb/releases). If downloads fail:
|
|
781
|
+
|
|
782
|
+
1. Check your internet connection
|
|
783
|
+
2. Verify GitHub isn't blocked by your firewall
|
|
784
|
+
3. Try again (SpinDB has automatic retry logic)
|
|
785
|
+
|
|
786
|
+
### Reset Everything
|
|
1133
787
|
|
|
1134
788
|
```bash
|
|
1135
789
|
rm -rf ~/.spindb
|
|
1136
790
|
```
|
|
1137
791
|
|
|
792
|
+
This deletes all containers, binaries, and configuration. Use with caution.
|
|
793
|
+
|
|
1138
794
|
---
|
|
1139
795
|
|
|
1140
796
|
## Contributing
|
|
1141
797
|
|
|
1142
|
-
|
|
798
|
+
We welcome contributions! SpinDB is built with:
|
|
1143
799
|
|
|
1144
|
-
|
|
800
|
+
- **Runtime:** Node.js 18+ with TypeScript
|
|
801
|
+
- **Execution:** `tsx` for direct TypeScript execution
|
|
802
|
+
- **Package Manager:** pnpm (strictly enforced)
|
|
803
|
+
- **CLI Framework:** Commander.js
|
|
804
|
+
- **Interactive UI:** Inquirer.js, Chalk, Ora
|
|
1145
805
|
|
|
1146
|
-
See [
|
|
806
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and testing guidelines.
|
|
807
|
+
|
|
808
|
+
See [ARCHITECTURE.md](ARCHITECTURE.md) for project architecture details.
|
|
1147
809
|
|
|
1148
810
|
See [CLAUDE.md](CLAUDE.md) for AI-assisted development context.
|
|
1149
811
|
|
|
1150
|
-
See [
|
|
812
|
+
See [FEATURE.md](FEATURE.md) for adding new database engines.
|
|
1151
813
|
|
|
1152
814
|
---
|
|
1153
815
|
|
|
1154
816
|
## Acknowledgments
|
|
1155
817
|
|
|
1156
|
-
SpinDB
|
|
818
|
+
SpinDB is powered by:
|
|
1157
819
|
|
|
1158
|
-
- **[hostdb](https://github.com/robertjbass/hostdb)** - Pre-compiled database binaries
|
|
820
|
+
- **[hostdb](https://github.com/robertjbass/hostdb)** - Pre-compiled database binaries for 9 engines across all major platforms. Makes Docker-free multi-version database support possible.
|
|
1159
821
|
|
|
1160
822
|
---
|
|
1161
823
|
|
|
@@ -1163,9 +825,26 @@ SpinDB wouldn't be possible without:
|
|
|
1163
825
|
|
|
1164
826
|
[PolyForm Noncommercial 1.0.0](LICENSE)
|
|
1165
827
|
|
|
1166
|
-
SpinDB is free for:
|
|
828
|
+
SpinDB is **free** for:
|
|
1167
829
|
- Personal use and hobby projects
|
|
1168
|
-
- Educational and
|
|
1169
|
-
-
|
|
830
|
+
- Educational institutions and students
|
|
831
|
+
- Academic and scientific research
|
|
832
|
+
- Nonprofit organizations
|
|
833
|
+
- Government agencies
|
|
834
|
+
|
|
835
|
+
**Commercial use requires a separate license.** For commercial licensing inquiries, please open an issue or contact the maintainer.
|
|
836
|
+
|
|
837
|
+
---
|
|
838
|
+
|
|
839
|
+
## Links
|
|
840
|
+
|
|
841
|
+
- **GitHub:** [github.com/robertjbass/spindb](https://github.com/robertjbass/spindb)
|
|
842
|
+
- **npm:** [npmjs.com/package/spindb](https://www.npmjs.com/package/spindb)
|
|
843
|
+
- **hostdb:** [github.com/robertjbass/hostdb](https://github.com/robertjbass/hostdb)
|
|
844
|
+
- **Issues:** [github.com/robertjbass/spindb/issues](https://github.com/robertjbass/spindb/issues)
|
|
845
|
+
|
|
846
|
+
---
|
|
847
|
+
|
|
848
|
+
**Questions? Found a bug? Have a feature request?**
|
|
1170
849
|
|
|
1171
|
-
|
|
850
|
+
Open an issue: [github.com/robertjbass/spindb/issues](https://github.com/robertjbass/spindb/issues)
|