kctl-dbgate 0.3.0__tar.gz
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.
- kctl_dbgate-0.3.0/.gitignore +33 -0
- kctl_dbgate-0.3.0/PKG-INFO +289 -0
- kctl_dbgate-0.3.0/README.md +264 -0
- kctl_dbgate-0.3.0/pyproject.toml +60 -0
- kctl_dbgate-0.3.0/skills/dbgate-admin/SKILL.md +170 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/__init__.py +1 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/__main__.py +3 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/cli.py +94 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/__init__.py +0 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/config_cmd.py +417 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/connections.py +572 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/doctor_cmd.py +171 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/health.py +67 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/history.py +80 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/plugins.py +96 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/query.py +197 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/servers.py +139 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/sessions.py +72 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/skill_cmd.py +74 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/commands/storage.py +36 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/__init__.py +0 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/callbacks.py +32 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/client.py +172 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/config.py +134 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/exceptions.py +21 -0
- kctl_dbgate-0.3.0/src/kctl_dbgate/core/plugins.py +13 -0
- kctl_dbgate-0.3.0/tests/__init__.py +0 -0
- kctl_dbgate-0.3.0/tests/commands/__init__.py +0 -0
- kctl_dbgate-0.3.0/tests/commands/conftest.py +15 -0
- kctl_dbgate-0.3.0/tests/commands/test_config_server.py +89 -0
- kctl_dbgate-0.3.0/tests/commands/test_connections.py +574 -0
- kctl_dbgate-0.3.0/tests/commands/test_doctor.py +81 -0
- kctl_dbgate-0.3.0/tests/commands/test_history.py +59 -0
- kctl_dbgate-0.3.0/tests/commands/test_plugins.py +70 -0
- kctl_dbgate-0.3.0/tests/commands/test_query.py +222 -0
- kctl_dbgate-0.3.0/tests/commands/test_servers.py +102 -0
- kctl_dbgate-0.3.0/tests/commands/test_sessions.py +55 -0
- kctl_dbgate-0.3.0/tests/commands/test_storage.py +50 -0
- kctl_dbgate-0.3.0/tests/conftest.py +58 -0
- kctl_dbgate-0.3.0/tests/core/__init__.py +0 -0
- kctl_dbgate-0.3.0/tests/core/test_client.py +135 -0
- kctl_dbgate-0.3.0/tests/test_smoke.py +21 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.eggs/
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
|
|
14
|
+
# IDE
|
|
15
|
+
.idea/
|
|
16
|
+
.vscode/
|
|
17
|
+
*.swp
|
|
18
|
+
*.swo
|
|
19
|
+
|
|
20
|
+
# Testing
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
htmlcov/
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.ruff_cache/
|
|
26
|
+
|
|
27
|
+
# OS
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
|
|
31
|
+
# Environment
|
|
32
|
+
.env
|
|
33
|
+
.env.local
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kctl-dbgate
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Kodemeio DBGate CLI - manage DBGate web-based database management UI
|
|
5
|
+
Author-email: Kodemeio <dev@kodeme.io>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: admin,cli,database,dbgate,kodemeio
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: System Administrators
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: System :: Systems Administration
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: httpx>=0.28.0
|
|
17
|
+
Requires-Dist: kctl-lib>=0.4.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: mypy>=1.14.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-httpx>=0.35.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=8.3.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff>=0.9.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# kctl-dbgate
|
|
27
|
+
|
|
28
|
+
CLI for [DBGate](https://dbgate.org/) — the web-based database management UI. Part of the Kodemeio `kctl-*` family (shared config at `~/.config/kodemeio/config.yaml`, scoped under `dbgate`).
|
|
29
|
+
|
|
30
|
+
**Version:** 0.2.0 — wraps ~70 of DBGate's 121 REST endpoints across 10 command groups.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
From the workspace root:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv sync # installs all kctl-* packages
|
|
38
|
+
uv tool install --editable packages/kctl-dbgate # makes `kctl-dbgate` globally available
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configure
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Interactive
|
|
45
|
+
kctl-dbgate config init
|
|
46
|
+
|
|
47
|
+
# Or explicit
|
|
48
|
+
kctl-dbgate config set url https://dbgate.local.kodeme.io
|
|
49
|
+
kctl-dbgate config set login admin
|
|
50
|
+
kctl-dbgate config set password '<your-password>'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Config is saved under the active profile in `~/.config/kodemeio/config.yaml`:
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
default_profile: kodemeio
|
|
57
|
+
profiles:
|
|
58
|
+
kodemeio:
|
|
59
|
+
dbgate:
|
|
60
|
+
url: https://dbgate.local.kodeme.io
|
|
61
|
+
login: admin
|
|
62
|
+
password: ****
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Use `-p <profile>` to target a different tenant:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
kctl-dbgate -p idtpp connections list
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Env var overrides
|
|
72
|
+
|
|
73
|
+
| Variable | Purpose |
|
|
74
|
+
|----------|---------|
|
|
75
|
+
| `KCTL_DBGATE_URL` | Override URL |
|
|
76
|
+
| `KCTL_DBGATE_LOGIN` | Override login |
|
|
77
|
+
| `KCTL_DBGATE_PASSWORD` | Override password |
|
|
78
|
+
| `KCTL_DBGATE_PROFILE` | Default profile name |
|
|
79
|
+
|
|
80
|
+
## Command groups
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
kctl-dbgate --help
|
|
84
|
+
|
|
85
|
+
┌─────────────┬──────────────────────────────────────────────────────────┐
|
|
86
|
+
│ config │ CLI profile management + DBGate server settings │
|
|
87
|
+
│ health │ HTTP + auth + container quick check │
|
|
88
|
+
│ doctor │ 6 diagnostic checks with --fix hints │
|
|
89
|
+
│ connections │ CRUD for DBGate connection definitions │
|
|
90
|
+
│ servers │ Server-level DB operations (ping, create-db, drop-db) │
|
|
91
|
+
│ query │ SQL/script execution with --format/--file/--var │
|
|
92
|
+
│ sessions │ Query session lifecycle (create, kill) │
|
|
93
|
+
│ plugins │ DBGate plugin install/uninstall/upgrade │
|
|
94
|
+
│ history │ Query history read/write │
|
|
95
|
+
│ storage │ Admin-password rotation │
|
|
96
|
+
└─────────────┴──────────────────────────────────────────────────────────┘
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Run any subcommand with `--help` for full flag documentation. All commands honor the global flags: `--json`, `--format {pretty,json,csv,yaml,tsv}`, `--no-header`, `--quiet`.
|
|
100
|
+
|
|
101
|
+
## Connections
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# List all connections (shows `Source` column: "user" vs "env")
|
|
105
|
+
kctl-dbgate connections list
|
|
106
|
+
|
|
107
|
+
# Detail
|
|
108
|
+
kctl-dbgate connections get <connection_id>
|
|
109
|
+
|
|
110
|
+
# Test reachability (uses DBGate's own /connections/test)
|
|
111
|
+
kctl-dbgate connections test <connection_id>
|
|
112
|
+
|
|
113
|
+
# Create a new one (Postgres example)
|
|
114
|
+
kctl-dbgate connections create \
|
|
115
|
+
--label "dokploy-postgres" \
|
|
116
|
+
--engine postgres@dbgate-plugin-postgres \
|
|
117
|
+
--server 10.0.0.3 \
|
|
118
|
+
--port 5432 \
|
|
119
|
+
--user app --password '…' \
|
|
120
|
+
--database dokploy
|
|
121
|
+
|
|
122
|
+
# Update (only pass flags for fields you want to change)
|
|
123
|
+
kctl-dbgate connections update <connection_id> --password 'new-password'
|
|
124
|
+
|
|
125
|
+
# Delete
|
|
126
|
+
kctl-dbgate connections delete <connection_id> --force
|
|
127
|
+
|
|
128
|
+
# SQLite / DuckDB databases (file-based)
|
|
129
|
+
kctl-dbgate connections new-sqlite --label metrics --file /data/metrics.db
|
|
130
|
+
kctl-dbgate connections new-duckdb --label analytics --file /data/analytics.duckdb
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Engine strings
|
|
134
|
+
|
|
135
|
+
| Database | `--engine` value |
|
|
136
|
+
|----------|------------------|
|
|
137
|
+
| PostgreSQL | `postgres@dbgate-plugin-postgres` |
|
|
138
|
+
| MySQL / MariaDB | `mysql@dbgate-plugin-mysql` |
|
|
139
|
+
| MSSQL | `mssql@dbgate-plugin-mssql` |
|
|
140
|
+
| MongoDB | `mongo@dbgate-plugin-mongo` |
|
|
141
|
+
| Redis | `redis@dbgate-plugin-redis` |
|
|
142
|
+
| SQLite | `sqlite@dbgate-plugin-sqlite` |
|
|
143
|
+
| DuckDB | `duckdb@dbgate-plugin-duckdb` |
|
|
144
|
+
| Oracle | `oracle@dbgate-plugin-oracle` |
|
|
145
|
+
|
|
146
|
+
## Servers (server-level DB operations)
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
kctl-dbgate servers ping <connection_id> # just-connected check
|
|
150
|
+
kctl-dbgate servers summary <connection_id> # database list on this server
|
|
151
|
+
kctl-dbgate servers create-database <connection_id> --name mydb
|
|
152
|
+
kctl-dbgate servers drop-database <connection_id> --name mydb --force
|
|
153
|
+
kctl-dbgate servers refresh <connection_id> # refresh metadata cache
|
|
154
|
+
kctl-dbgate servers disconnect <connection_id> # force disconnect
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Query
|
|
158
|
+
|
|
159
|
+
Execute SQL directly (or JS scripts for Mongo):
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Inline SQL
|
|
163
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
164
|
+
--sql "SELECT version()"
|
|
165
|
+
|
|
166
|
+
# From a file
|
|
167
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
168
|
+
--file schema.sql
|
|
169
|
+
|
|
170
|
+
# With variable substitution (`{{var}}` → value)
|
|
171
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
172
|
+
--sql "SELECT * FROM {{table}} LIMIT {{n}}" \
|
|
173
|
+
--var table=users --var n=10 \
|
|
174
|
+
--format csv
|
|
175
|
+
|
|
176
|
+
# SELECT convenience
|
|
177
|
+
kctl-dbgate query select --connection <id> --database dokploy \
|
|
178
|
+
--table users --where "active = true" --limit 100
|
|
179
|
+
|
|
180
|
+
# Preview (doesn't execute)
|
|
181
|
+
kctl-dbgate query preview --connection <id> --database dokploy \
|
|
182
|
+
--sql "DROP TABLE users"
|
|
183
|
+
|
|
184
|
+
# Mongo / NoSQL JS scripts
|
|
185
|
+
kctl-dbgate query eval --connection <mongo_id> --database mydb \
|
|
186
|
+
--script aggregations.js
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Note on `--var`:** simple string substitution, not SQL-parameterized. Don't pass untrusted input.
|
|
190
|
+
|
|
191
|
+
## Sessions
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
kctl-dbgate sessions create --connection <id> --database mydb
|
|
195
|
+
kctl-dbgate sessions kill <session_id>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Plugins
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
kctl-dbgate plugins list
|
|
202
|
+
kctl-dbgate plugins install dbgate-plugin-csv
|
|
203
|
+
kctl-dbgate plugins upgrade dbgate-plugin-csv
|
|
204
|
+
kctl-dbgate plugins uninstall dbgate-plugin-csv
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Config (CLI profiles + DBGate server settings)
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# CLI profile mgmt (stored in ~/.config/kodemeio/config.yaml)
|
|
211
|
+
kctl-dbgate config init
|
|
212
|
+
kctl-dbgate config show
|
|
213
|
+
kctl-dbgate config set <key> <value>
|
|
214
|
+
kctl-dbgate config use <profile>
|
|
215
|
+
kctl-dbgate config profiles
|
|
216
|
+
kctl-dbgate config current
|
|
217
|
+
kctl-dbgate config remove <profile> [--force] [--service-only]
|
|
218
|
+
|
|
219
|
+
# DBGate server settings (stored in /root/.dbgate/ on the server)
|
|
220
|
+
kctl-dbgate config server-show # POST /config/get
|
|
221
|
+
kctl-dbgate config server-set --key <k> --value <v>
|
|
222
|
+
kctl-dbgate config server-changelog # DBGate changelog
|
|
223
|
+
kctl-dbgate config server-export settings.yaml # export server settings + connections
|
|
224
|
+
kctl-dbgate config server-import settings.yaml # import
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## History
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
kctl-dbgate history list # latest queries
|
|
231
|
+
kctl-dbgate history add --connection <id> --sql "..." # append a record
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Health & Doctor
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
kctl-dbgate health check # quick live check (HTTP + auth + container)
|
|
238
|
+
kctl-dbgate doctor # full 6-check diagnostic with fix hints
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Doctor checks: URL configured → credentials configured → HTTP reachable → login succeeds → `/config/get` readable → server-summary reachable (skipped if no connections).
|
|
242
|
+
|
|
243
|
+
## Storage
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Rotate DBGate's admin password (persisted to /root/.dbgate/user.json)
|
|
247
|
+
kctl-dbgate storage set-admin-password --password 'new-password'
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Global flags
|
|
251
|
+
|
|
252
|
+
Every command supports:
|
|
253
|
+
|
|
254
|
+
| Flag | Purpose |
|
|
255
|
+
|------|---------|
|
|
256
|
+
| `-p, --profile` | Select kctl-dbgate profile |
|
|
257
|
+
| `--url` / `--login` / `--password` | Per-invocation override (no profile state change) |
|
|
258
|
+
| `-f, --format` | `pretty` (default), `json`, `csv`, `tsv`, `yaml` |
|
|
259
|
+
| `--json` | Shortcut for `--format json` |
|
|
260
|
+
| `--no-header` | Omit header row in CSV/TSV |
|
|
261
|
+
| `--quiet` / `-q` | Suppress info messages |
|
|
262
|
+
| `-V, --version` | Print version and exit |
|
|
263
|
+
|
|
264
|
+
## API coverage
|
|
265
|
+
|
|
266
|
+
- **Wrapped (≈ 70):** everything under `connections`, `server-connections`, `database-connections` (query surface), `config`, `sessions`, `plugins`, `query-history`, `storage`, plus `auth/login` for session bootstrap.
|
|
267
|
+
- **Skipped (≈ 50):** `archive/*`, `apps/*`, `jsldata/*`, `files/*`, `runners/*`, `uploads/*`, `connections/dblogin-*`, `auth/oauth-*`. These are UI-state / plugin-internal endpoints with no CLI value.
|
|
268
|
+
|
|
269
|
+
Full endpoint inventory: 121 endpoints across 15 groups. See `/tmp/dbgate-endpoints.txt` (generated via `grep -oE 'apiCall\("[^"]+' /home/dbgate-docker/public/build/bundle.js`).
|
|
270
|
+
|
|
271
|
+
## Known upstream issue
|
|
272
|
+
|
|
273
|
+
`plugins install <package>` currently fails at the Node layer inside DBGate with a path-resolution error. The CLI payload is correct per `bundle.js` — this is a server-side issue. Install plugins via the web UI for now.
|
|
274
|
+
|
|
275
|
+
## Development
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
cd packages/kctl-dbgate
|
|
279
|
+
uv run pytest -q # 52 tests
|
|
280
|
+
uv run ruff check src/ tests/
|
|
281
|
+
uv run mypy src/ --strict
|
|
282
|
+
uv run kctl-dbgate --help
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Test harness uses `pytest-httpx` for HTTP mocking — no live network calls in tests.
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# kctl-dbgate
|
|
2
|
+
|
|
3
|
+
CLI for [DBGate](https://dbgate.org/) — the web-based database management UI. Part of the Kodemeio `kctl-*` family (shared config at `~/.config/kodemeio/config.yaml`, scoped under `dbgate`).
|
|
4
|
+
|
|
5
|
+
**Version:** 0.2.0 — wraps ~70 of DBGate's 121 REST endpoints across 10 command groups.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
From the workspace root:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv sync # installs all kctl-* packages
|
|
13
|
+
uv tool install --editable packages/kctl-dbgate # makes `kctl-dbgate` globally available
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configure
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Interactive
|
|
20
|
+
kctl-dbgate config init
|
|
21
|
+
|
|
22
|
+
# Or explicit
|
|
23
|
+
kctl-dbgate config set url https://dbgate.local.kodeme.io
|
|
24
|
+
kctl-dbgate config set login admin
|
|
25
|
+
kctl-dbgate config set password '<your-password>'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Config is saved under the active profile in `~/.config/kodemeio/config.yaml`:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
default_profile: kodemeio
|
|
32
|
+
profiles:
|
|
33
|
+
kodemeio:
|
|
34
|
+
dbgate:
|
|
35
|
+
url: https://dbgate.local.kodeme.io
|
|
36
|
+
login: admin
|
|
37
|
+
password: ****
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use `-p <profile>` to target a different tenant:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
kctl-dbgate -p idtpp connections list
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Env var overrides
|
|
47
|
+
|
|
48
|
+
| Variable | Purpose |
|
|
49
|
+
|----------|---------|
|
|
50
|
+
| `KCTL_DBGATE_URL` | Override URL |
|
|
51
|
+
| `KCTL_DBGATE_LOGIN` | Override login |
|
|
52
|
+
| `KCTL_DBGATE_PASSWORD` | Override password |
|
|
53
|
+
| `KCTL_DBGATE_PROFILE` | Default profile name |
|
|
54
|
+
|
|
55
|
+
## Command groups
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
kctl-dbgate --help
|
|
59
|
+
|
|
60
|
+
┌─────────────┬──────────────────────────────────────────────────────────┐
|
|
61
|
+
│ config │ CLI profile management + DBGate server settings │
|
|
62
|
+
│ health │ HTTP + auth + container quick check │
|
|
63
|
+
│ doctor │ 6 diagnostic checks with --fix hints │
|
|
64
|
+
│ connections │ CRUD for DBGate connection definitions │
|
|
65
|
+
│ servers │ Server-level DB operations (ping, create-db, drop-db) │
|
|
66
|
+
│ query │ SQL/script execution with --format/--file/--var │
|
|
67
|
+
│ sessions │ Query session lifecycle (create, kill) │
|
|
68
|
+
│ plugins │ DBGate plugin install/uninstall/upgrade │
|
|
69
|
+
│ history │ Query history read/write │
|
|
70
|
+
│ storage │ Admin-password rotation │
|
|
71
|
+
└─────────────┴──────────────────────────────────────────────────────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Run any subcommand with `--help` for full flag documentation. All commands honor the global flags: `--json`, `--format {pretty,json,csv,yaml,tsv}`, `--no-header`, `--quiet`.
|
|
75
|
+
|
|
76
|
+
## Connections
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# List all connections (shows `Source` column: "user" vs "env")
|
|
80
|
+
kctl-dbgate connections list
|
|
81
|
+
|
|
82
|
+
# Detail
|
|
83
|
+
kctl-dbgate connections get <connection_id>
|
|
84
|
+
|
|
85
|
+
# Test reachability (uses DBGate's own /connections/test)
|
|
86
|
+
kctl-dbgate connections test <connection_id>
|
|
87
|
+
|
|
88
|
+
# Create a new one (Postgres example)
|
|
89
|
+
kctl-dbgate connections create \
|
|
90
|
+
--label "dokploy-postgres" \
|
|
91
|
+
--engine postgres@dbgate-plugin-postgres \
|
|
92
|
+
--server 10.0.0.3 \
|
|
93
|
+
--port 5432 \
|
|
94
|
+
--user app --password '…' \
|
|
95
|
+
--database dokploy
|
|
96
|
+
|
|
97
|
+
# Update (only pass flags for fields you want to change)
|
|
98
|
+
kctl-dbgate connections update <connection_id> --password 'new-password'
|
|
99
|
+
|
|
100
|
+
# Delete
|
|
101
|
+
kctl-dbgate connections delete <connection_id> --force
|
|
102
|
+
|
|
103
|
+
# SQLite / DuckDB databases (file-based)
|
|
104
|
+
kctl-dbgate connections new-sqlite --label metrics --file /data/metrics.db
|
|
105
|
+
kctl-dbgate connections new-duckdb --label analytics --file /data/analytics.duckdb
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Engine strings
|
|
109
|
+
|
|
110
|
+
| Database | `--engine` value |
|
|
111
|
+
|----------|------------------|
|
|
112
|
+
| PostgreSQL | `postgres@dbgate-plugin-postgres` |
|
|
113
|
+
| MySQL / MariaDB | `mysql@dbgate-plugin-mysql` |
|
|
114
|
+
| MSSQL | `mssql@dbgate-plugin-mssql` |
|
|
115
|
+
| MongoDB | `mongo@dbgate-plugin-mongo` |
|
|
116
|
+
| Redis | `redis@dbgate-plugin-redis` |
|
|
117
|
+
| SQLite | `sqlite@dbgate-plugin-sqlite` |
|
|
118
|
+
| DuckDB | `duckdb@dbgate-plugin-duckdb` |
|
|
119
|
+
| Oracle | `oracle@dbgate-plugin-oracle` |
|
|
120
|
+
|
|
121
|
+
## Servers (server-level DB operations)
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
kctl-dbgate servers ping <connection_id> # just-connected check
|
|
125
|
+
kctl-dbgate servers summary <connection_id> # database list on this server
|
|
126
|
+
kctl-dbgate servers create-database <connection_id> --name mydb
|
|
127
|
+
kctl-dbgate servers drop-database <connection_id> --name mydb --force
|
|
128
|
+
kctl-dbgate servers refresh <connection_id> # refresh metadata cache
|
|
129
|
+
kctl-dbgate servers disconnect <connection_id> # force disconnect
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Query
|
|
133
|
+
|
|
134
|
+
Execute SQL directly (or JS scripts for Mongo):
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Inline SQL
|
|
138
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
139
|
+
--sql "SELECT version()"
|
|
140
|
+
|
|
141
|
+
# From a file
|
|
142
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
143
|
+
--file schema.sql
|
|
144
|
+
|
|
145
|
+
# With variable substitution (`{{var}}` → value)
|
|
146
|
+
kctl-dbgate query run --connection <id> --database dokploy \
|
|
147
|
+
--sql "SELECT * FROM {{table}} LIMIT {{n}}" \
|
|
148
|
+
--var table=users --var n=10 \
|
|
149
|
+
--format csv
|
|
150
|
+
|
|
151
|
+
# SELECT convenience
|
|
152
|
+
kctl-dbgate query select --connection <id> --database dokploy \
|
|
153
|
+
--table users --where "active = true" --limit 100
|
|
154
|
+
|
|
155
|
+
# Preview (doesn't execute)
|
|
156
|
+
kctl-dbgate query preview --connection <id> --database dokploy \
|
|
157
|
+
--sql "DROP TABLE users"
|
|
158
|
+
|
|
159
|
+
# Mongo / NoSQL JS scripts
|
|
160
|
+
kctl-dbgate query eval --connection <mongo_id> --database mydb \
|
|
161
|
+
--script aggregations.js
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Note on `--var`:** simple string substitution, not SQL-parameterized. Don't pass untrusted input.
|
|
165
|
+
|
|
166
|
+
## Sessions
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
kctl-dbgate sessions create --connection <id> --database mydb
|
|
170
|
+
kctl-dbgate sessions kill <session_id>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Plugins
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
kctl-dbgate plugins list
|
|
177
|
+
kctl-dbgate plugins install dbgate-plugin-csv
|
|
178
|
+
kctl-dbgate plugins upgrade dbgate-plugin-csv
|
|
179
|
+
kctl-dbgate plugins uninstall dbgate-plugin-csv
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Config (CLI profiles + DBGate server settings)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# CLI profile mgmt (stored in ~/.config/kodemeio/config.yaml)
|
|
186
|
+
kctl-dbgate config init
|
|
187
|
+
kctl-dbgate config show
|
|
188
|
+
kctl-dbgate config set <key> <value>
|
|
189
|
+
kctl-dbgate config use <profile>
|
|
190
|
+
kctl-dbgate config profiles
|
|
191
|
+
kctl-dbgate config current
|
|
192
|
+
kctl-dbgate config remove <profile> [--force] [--service-only]
|
|
193
|
+
|
|
194
|
+
# DBGate server settings (stored in /root/.dbgate/ on the server)
|
|
195
|
+
kctl-dbgate config server-show # POST /config/get
|
|
196
|
+
kctl-dbgate config server-set --key <k> --value <v>
|
|
197
|
+
kctl-dbgate config server-changelog # DBGate changelog
|
|
198
|
+
kctl-dbgate config server-export settings.yaml # export server settings + connections
|
|
199
|
+
kctl-dbgate config server-import settings.yaml # import
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## History
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
kctl-dbgate history list # latest queries
|
|
206
|
+
kctl-dbgate history add --connection <id> --sql "..." # append a record
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Health & Doctor
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
kctl-dbgate health check # quick live check (HTTP + auth + container)
|
|
213
|
+
kctl-dbgate doctor # full 6-check diagnostic with fix hints
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Doctor checks: URL configured → credentials configured → HTTP reachable → login succeeds → `/config/get` readable → server-summary reachable (skipped if no connections).
|
|
217
|
+
|
|
218
|
+
## Storage
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Rotate DBGate's admin password (persisted to /root/.dbgate/user.json)
|
|
222
|
+
kctl-dbgate storage set-admin-password --password 'new-password'
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Global flags
|
|
226
|
+
|
|
227
|
+
Every command supports:
|
|
228
|
+
|
|
229
|
+
| Flag | Purpose |
|
|
230
|
+
|------|---------|
|
|
231
|
+
| `-p, --profile` | Select kctl-dbgate profile |
|
|
232
|
+
| `--url` / `--login` / `--password` | Per-invocation override (no profile state change) |
|
|
233
|
+
| `-f, --format` | `pretty` (default), `json`, `csv`, `tsv`, `yaml` |
|
|
234
|
+
| `--json` | Shortcut for `--format json` |
|
|
235
|
+
| `--no-header` | Omit header row in CSV/TSV |
|
|
236
|
+
| `--quiet` / `-q` | Suppress info messages |
|
|
237
|
+
| `-V, --version` | Print version and exit |
|
|
238
|
+
|
|
239
|
+
## API coverage
|
|
240
|
+
|
|
241
|
+
- **Wrapped (≈ 70):** everything under `connections`, `server-connections`, `database-connections` (query surface), `config`, `sessions`, `plugins`, `query-history`, `storage`, plus `auth/login` for session bootstrap.
|
|
242
|
+
- **Skipped (≈ 50):** `archive/*`, `apps/*`, `jsldata/*`, `files/*`, `runners/*`, `uploads/*`, `connections/dblogin-*`, `auth/oauth-*`. These are UI-state / plugin-internal endpoints with no CLI value.
|
|
243
|
+
|
|
244
|
+
Full endpoint inventory: 121 endpoints across 15 groups. See `/tmp/dbgate-endpoints.txt` (generated via `grep -oE 'apiCall\("[^"]+' /home/dbgate-docker/public/build/bundle.js`).
|
|
245
|
+
|
|
246
|
+
## Known upstream issue
|
|
247
|
+
|
|
248
|
+
`plugins install <package>` currently fails at the Node layer inside DBGate with a path-resolution error. The CLI payload is correct per `bundle.js` — this is a server-side issue. Install plugins via the web UI for now.
|
|
249
|
+
|
|
250
|
+
## Development
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
cd packages/kctl-dbgate
|
|
254
|
+
uv run pytest -q # 52 tests
|
|
255
|
+
uv run ruff check src/ tests/
|
|
256
|
+
uv run mypy src/ --strict
|
|
257
|
+
uv run kctl-dbgate --help
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Test harness uses `pytest-httpx` for HTTP mocking — no live network calls in tests.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kctl-dbgate"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "Kodemeio DBGate CLI - manage DBGate web-based database management UI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
authors = [{ name = "Kodemeio", email = "dev@kodeme.io" }]
|
|
13
|
+
keywords = ["dbgate", "database", "admin", "cli", "kodemeio"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: System Administrators",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: System :: Systems Administration",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"kctl-lib>=0.4.0",
|
|
25
|
+
"httpx>=0.28.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
dev = [
|
|
30
|
+
"pytest>=8.3.0",
|
|
31
|
+
"pytest-httpx>=0.35.0",
|
|
32
|
+
"ruff>=0.9.0",
|
|
33
|
+
"mypy>=1.14.0",
|
|
34
|
+
"types-PyYAML>=6.0.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
kctl-dbgate = "kctl_dbgate.cli:_run"
|
|
39
|
+
|
|
40
|
+
[tool.uv.sources]
|
|
41
|
+
kctl-lib = { workspace = true }
|
|
42
|
+
|
|
43
|
+
[project.entry-points."kctl_dbgate.plugins"]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src/kctl_dbgate"]
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
target-version = "py312"
|
|
50
|
+
line-length = 120
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
select = ["E", "F", "I", "W", "UP", "B", "SIM"]
|
|
54
|
+
|
|
55
|
+
[tool.mypy]
|
|
56
|
+
python_version = "3.12"
|
|
57
|
+
strict = true
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|