db33studio 1.0.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.
Files changed (55) hide show
  1. db33studio-1.0.0/LICENSE +202 -0
  2. db33studio-1.0.0/MANIFEST.in +25 -0
  3. db33studio-1.0.0/PKG-INFO +405 -0
  4. db33studio-1.0.0/README.md +363 -0
  5. db33studio-1.0.0/pyproject.toml +76 -0
  6. db33studio-1.0.0/setup.cfg +4 -0
  7. db33studio-1.0.0/src/db33studio/__init__.py +3 -0
  8. db33studio-1.0.0/src/db33studio/__main__.py +6 -0
  9. db33studio-1.0.0/src/db33studio/db.py +307 -0
  10. db33studio-1.0.0/src/db33studio/engines/__init__.py +0 -0
  11. db33studio-1.0.0/src/db33studio/engines/base.py +477 -0
  12. db33studio-1.0.0/src/db33studio/engines/mysql.py +802 -0
  13. db33studio-1.0.0/src/db33studio/engines/postgres.py +687 -0
  14. db33studio-1.0.0/src/db33studio/engines/redis.py +627 -0
  15. db33studio-1.0.0/src/db33studio/engines/redis_commands.py +130 -0
  16. db33studio-1.0.0/src/db33studio/engines/registry.py +125 -0
  17. db33studio-1.0.0/src/db33studio/engines/sqlite.py +576 -0
  18. db33studio-1.0.0/src/db33studio/errors.py +9 -0
  19. db33studio-1.0.0/src/db33studio/handlers/__init__.py +10 -0
  20. db33studio-1.0.0/src/db33studio/handlers/connections.py +94 -0
  21. db33studio-1.0.0/src/db33studio/handlers/deps.py +51 -0
  22. db33studio-1.0.0/src/db33studio/handlers/index.py +88 -0
  23. db33studio-1.0.0/src/db33studio/handlers/query.py +52 -0
  24. db33studio-1.0.0/src/db33studio/handlers/redis.py +209 -0
  25. db33studio-1.0.0/src/db33studio/handlers/tables.py +76 -0
  26. db33studio-1.0.0/src/db33studio/handlers/tabs.py +42 -0
  27. db33studio-1.0.0/src/db33studio/jobs/__init__.py +0 -0
  28. db33studio-1.0.0/src/db33studio/jobs/projects.py +3 -0
  29. db33studio-1.0.0/src/db33studio/lib/__init__.py +0 -0
  30. db33studio-1.0.0/src/db33studio/lib/http_errors.py +18 -0
  31. db33studio-1.0.0/src/db33studio/lib/migrations.py +159 -0
  32. db33studio-1.0.0/src/db33studio/lib/response.py +87 -0
  33. db33studio-1.0.0/src/db33studio/logs.py +3 -0
  34. db33studio-1.0.0/src/db33studio/main.py +62 -0
  35. db33studio-1.0.0/src/db33studio/migrations/0002_connections.down.sql +1 -0
  36. db33studio-1.0.0/src/db33studio/migrations/0002_connections.up.sql +15 -0
  37. db33studio-1.0.0/src/db33studio/migrations/0003_workspace_tabs.down.sql +2 -0
  38. db33studio-1.0.0/src/db33studio/migrations/0003_workspace_tabs.up.sql +26 -0
  39. db33studio-1.0.0/src/db33studio/model/__init__.py +0 -0
  40. db33studio-1.0.0/src/db33studio/model/connections/__init__.py +0 -0
  41. db33studio-1.0.0/src/db33studio/model/connections/dto.py +71 -0
  42. db33studio-1.0.0/src/db33studio/model/connections/service.py +225 -0
  43. db33studio-1.0.0/src/db33studio/model/tabs/__init__.py +0 -0
  44. db33studio-1.0.0/src/db33studio/model/tabs/dto.py +64 -0
  45. db33studio-1.0.0/src/db33studio/model/tabs/service.py +63 -0
  46. db33studio-1.0.0/src/db33studio/server.py +20 -0
  47. db33studio-1.0.0/src/db33studio/webui/assets/index-BcHKGlt4.js +52 -0
  48. db33studio-1.0.0/src/db33studio/webui/assets/index-jCXeM1xx.css +2 -0
  49. db33studio-1.0.0/src/db33studio/webui/index.html +39 -0
  50. db33studio-1.0.0/src/db33studio.egg-info/PKG-INFO +405 -0
  51. db33studio-1.0.0/src/db33studio.egg-info/SOURCES.txt +53 -0
  52. db33studio-1.0.0/src/db33studio.egg-info/dependency_links.txt +1 -0
  53. db33studio-1.0.0/src/db33studio.egg-info/entry_points.txt +2 -0
  54. db33studio-1.0.0/src/db33studio.egg-info/requires.txt +15 -0
  55. db33studio-1.0.0/src/db33studio.egg-info/top_level.txt +1 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,25 @@
1
+ # Build inputs for the sdist. The wheel gets its package data from
2
+ # [tool.setuptools.package-data] in pyproject.toml.
3
+ include pyproject.toml
4
+ include README.md
5
+ include LICENSE
6
+
7
+ # Compiled UI and SQL migrations: generated or required at runtime, so graft
8
+ # them explicitly instead of relying on git tracking.
9
+ graft src/db33studio/webui
10
+ graft src/db33studio/migrations
11
+
12
+ # The Svelte source (web/src, web/node_modules, web/dist), the test suite and
13
+ # local state are never part of a distribution.
14
+ prune web
15
+ prune tests
16
+ prune data
17
+ prune .raggie
18
+ prune dist
19
+ prune build
20
+ prune .pytest_cache
21
+
22
+ exclude .env
23
+ global-exclude __pycache__
24
+ global-exclude *.py[cod]
25
+ global-exclude .DS_Store
@@ -0,0 +1,405 @@
1
+ Metadata-Version: 2.4
2
+ Name: db33studio
3
+ Version: 1.0.0
4
+ Summary: A local, single-user database client for PostgreSQL, MySQL, SQLite and Redis.
5
+ Author: hussein
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hussein/db33studio
8
+ Project-URL: Repository, https://github.com/hussein/db33studio
9
+ Project-URL: Issues, https://github.com/hussein/db33studio/issues
10
+ Keywords: database,database-client,sqlite,postgresql,mysql,redis
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Framework :: FastAPI
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Database :: Front-Ends
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: fastapi==0.163.2
28
+ Requires-Dist: uvicorn[standard]==0.54.0
29
+ Requires-Dist: python-dotenv==1.2.4
30
+ Requires-Dist: pydantic==2.14.3
31
+ Requires-Dist: structlog==26.1.0
32
+ Requires-Dist: aiosqlite==0.21.0
33
+ Requires-Dist: psycopg[binary]==3.3.4
34
+ Requires-Dist: aiomysql==0.3.2
35
+ Requires-Dist: redis==8.2.0
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest==9.2.0; extra == "dev"
38
+ Requires-Dist: httpx==0.28.1; extra == "dev"
39
+ Requires-Dist: pytest-asyncio==1.5.0; extra == "dev"
40
+ Requires-Dist: fakeredis==2.41.0; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # DB Client
44
+
45
+ A local, single-user database client for **PostgreSQL**, **MySQL**, **SQLite**
46
+ and **Redis**. One FastAPI backend, one Svelte 5 single-page app. It gives you
47
+ the everyday parts of a desktop DB tool in the browser: a schema tree, a paged
48
+ data grid with raw `WHERE` / `ORDER BY`, a structure view with constraints,
49
+ indexes, foreign keys and DDL, a SQL editor with multi-statement results, and a
50
+ Redis key browser with a command bar.
51
+
52
+ ![Table data, dark theme](docs/screenshots/table-data-dark.png)
53
+
54
+ ## Features
55
+
56
+ | | PostgreSQL | MySQL / MariaDB | SQLite | Redis |
57
+ | --- | --- | --- | --- | --- |
58
+ | Save / test / edit connections | yes | yes | yes | yes |
59
+ | Schema tree (tables, views, enums) | yes | yes (databases as schemas) | tables + views | logical DB |
60
+ | Paged table data, filter, sort, inspect | yes | yes | yes | not applicable |
61
+ | Row inspector with FK navigation | yes | yes | yes | not applicable |
62
+ | Structure: columns, keys, constraints, indexes | yes | yes | yes | not applicable |
63
+ | Table DDL | reconstructed | `SHOW CREATE TABLE` | from `sqlite_master` | not applicable |
64
+ | SQL editor, multi-statement | yes | yes | yes | command bar instead |
65
+ | Read-only SQLite file mode | - | - | yes | - |
66
+ | Key browser with SCAN and type filter | - | - | - | yes |
67
+ | Key detail for string/hash/list/set/zset/stream | - | - | - | yes |
68
+ | Command bar with admin-command blocklist | - | - | - | yes |
69
+ | TTL / rename / delete keys | - | - | - | yes |
70
+
71
+ Every SQL engine supports connection testing with the server version and
72
+ latency, CSV export of the loaded rows, and both themes. Redis connections test
73
+ the same way and open the key browser instead of the table and query tabs.
74
+
75
+ ## Project layout
76
+
77
+ ```
78
+ src/db33studio/ Python package: FastAPI app, engines, handlers, SQL migrations
79
+ web/ Svelte 5 + TypeScript + Tailwind source for the UI
80
+ scripts/ build_ui.py (stage the compiled UI), seed_demo.py
81
+ tests/ pytest suite
82
+ docs/ API contract, engine notes, screenshots
83
+ ```
84
+
85
+ ## Architecture
86
+
87
+ ```
88
+ src/db33studio/ FastAPI package and all target-database access
89
+ main.py server.py entrypoint, app factory, lifespan (migrations)
90
+ db.py aiosqlite wrapper for the local metadata store
91
+ engines/
92
+ base.py Engine ABC, dataclasses, identifier/value/SQL helpers
93
+ registry.py open_engine(record), test_engine(record)
94
+ sqlite.py postgres.py mysql.py redis.py
95
+ redis_commands.py Redis command tokenizer + blocklist (pure functions)
96
+ model/connections/ Pydantic DTOs and the connections service
97
+ model/tabs/ workspace tab DTOs and the tabs service
98
+ handlers/ thin routers: connections, tables, query, redis, tabs, UI
99
+ lib/ response envelope, errors, migrations
100
+ migrations/ the app's own SQLite schema
101
+ webui/ compiled UI, written by scripts/build_ui.py (gitignored)
102
+
103
+ web/ Svelte 5 + TypeScript + Tailwind v4 SPA
104
+ src/App.svelte shell, routing between screens
105
+ src/lib/api/ typed client: connections, schema, query, redis, tabs
106
+ src/lib/stores/ theme, layout panels, connections, workspace tabs, catalog, toasts
107
+ src/lib/tabs.ts tab reordering and id helpers, pure functions
108
+ src/lib/lines.ts line counts and gutter widths, pure functions
109
+ src/lib/components/
110
+ layout/ title bar, connection rail, jump search, theme toggle
111
+ connections/ new/edit connection screen
112
+ schema/ object tree
113
+ data/ data grid shared by the table and query tabs
114
+ workspace/ tab strip with drag reorder, empty state
115
+ table/ table tab: data, filters, inspector, structure
116
+ query/ SQL editor and per-statement results
117
+ highlight/ per-dialect highlighting for the query editor and Redis command bar
118
+ redis/ key list, key detail, command bar
119
+ ui/ buttons, inputs, badges, modal, toasts, icons
120
+ tests/ vitest for pure helpers
121
+
122
+ scripts/
123
+ build_ui.py builds web/, copies web/dist into src/db33studio/webui
124
+ seed_demo.py reproducible SQLite demo database
125
+ tests/ pytest suite
126
+ docs/ CONTRACT.md, db.md, engines.md, screenshots/
127
+ ```
128
+
129
+ Handlers never talk to a driver. They resolve the saved connection, open one
130
+ engine from `engines/registry.py` for the request, and close it again. Engines
131
+ are the only place with dialect SQL. The full API and data-shape contract lives
132
+ in [docs/CONTRACT.md](docs/CONTRACT.md).
133
+
134
+ ## Requirements
135
+
136
+ - Python 3.11+ (tested on 3.14)
137
+ - Node 20.19+ and npm (tested on Node 24, npm 12)
138
+ - A reachable PostgreSQL / MySQL / Redis server only if you want to use those
139
+ engines. SQLite needs nothing extra.
140
+
141
+ ## Setup and run
142
+
143
+ From the repo root:
144
+
145
+ ```bash
146
+ python3 -m venv .venv
147
+ . .venv/bin/activate
148
+ python -m pip install -e ".[dev]"
149
+
150
+ python scripts/build_ui.py # builds web/ and copies the compiled UI into src/db33studio/webui
151
+ python -m db33studio --debug # or: db33studio --debug -> http://127.0.0.1:2100
152
+ ```
153
+
154
+ The editable install pulls the runtime and dev dependencies from
155
+ `pyproject.toml`; there is no `requirements.txt`. `scripts/build_ui.py` installs
156
+ the npm packages if `web/node_modules` is missing, runs `npm run build`, and
157
+ stages `web/dist` into `src/db33studio/webui` where the server serves it from.
158
+ Run the suite with `python -m pytest` from the repo root.
159
+
160
+ Copy `.env.example` to `.env` if you want to change the defaults; the built-in
161
+ defaults work as-is.
162
+
163
+ For UI work with hot reload, run Vite in a second terminal:
164
+
165
+ ```bash
166
+ cd web
167
+ npm install
168
+ npm run dev # http://localhost:5173
169
+ ```
170
+
171
+ Vite proxies `/api` to `127.0.0.1:2100`. For a production build,
172
+ `npm run build` writes `web/dist`; serve it from any static server that proxies
173
+ `/api` to the backend, or set `VITE_API_BASE` to an absolute API URL at build
174
+ time.
175
+
176
+ Environment variables (see `.env.example`):
177
+
178
+ | variable | default | meaning |
179
+ | --- | --- | --- |
180
+ | `HOST` | `127.0.0.1` | bind address when not running `--debug` |
181
+ | `PORT` | `2100` | backend port |
182
+ | `DATABASE_PATH` | per-user data dir | optional path to the app's own SQLite file with saved connections |
183
+ | `QUERY_TIMEOUT_SECONDS` | `30` | per-request budget for tables, queries and Redis |
184
+
185
+ The server binds loopback only, because the app has no authentication and its
186
+ metadata file holds saved passwords. Set `HOST=0.0.0.0` deliberately if you want
187
+ to reach it from another machine, and treat that as exposing your databases.
188
+ `--debug` also binds `127.0.0.1`, and additionally enables auto-reload.
189
+
190
+ ## Demo database
191
+
192
+ The SQLite demo is reproducible and safe to re-run (it rewrites
193
+ `data/demo.db` only):
194
+
195
+ ```bash
196
+ python scripts/seed_demo.py
197
+ # Seeded .../data/demo.db with 10 customers and 40 orders.
198
+ ```
199
+
200
+ Then create a connection in the UI with engine SQLite and the absolute path to
201
+ `data/demo.db`. The database has `customers`, `orders` (FK, check
202
+ constraints, NULLs, two indexes) and a `daily_revenue` view.
203
+
204
+ For Redis, any reachable server works. The browser uses `SCAN`, never `KEYS`,
205
+ so an empty database simply shows the empty state.
206
+
207
+ ## How to use it
208
+
209
+ 1. **Connect.** First run opens the connection screen. Pick an engine, fill in
210
+ the form, press **Test** (server version and latency appear), then **Save &
211
+ connect**. Saved connections stay available in the rail on the left; the
212
+ chip in the title bar reopens the editor.
213
+ 2. **Browse.** The object tree groups tables, views and enums. The filter box is
214
+ local and instant. `Ctrl/Cmd+K` jumps to any table or view. The panel button
215
+ beside the logo, or `Ctrl/Cmd+B`, hides the sidebar; the Redis key list uses
216
+ the same toggle, and the choice is remembered per browser. With the sidebar
217
+ hidden the main pane takes the full width.
218
+ 3. **Table data.** Column headers show type, `PK` and `FK` badges. Use the
219
+ `WHERE` and `ORDER BY` inputs for raw SQL fragments, choose a page size and
220
+ press Apply. Click a row number to open the inspector; foreign keys get an
221
+ "Open ... row" button that opens the target table filtered to that value. The
222
+ inspector is a right sidebar with its own panel toggle in the table toolbar,
223
+ also remembered per browser.
224
+ 4. **Structure.** Switch the toolbar to Structure for columns, constraints,
225
+ indexes, the foreign-key graph and the DDL. The DDL block has a line-number
226
+ gutter that stays in place while the code scrolls sideways; the numbers are
227
+ decorative, so they never end up in a copy. Constraint definitions, index
228
+ definitions and the DDL block are highlighted with the connection's dialect,
229
+ and long definitions wrap instead of clipping. Copy or export the DDL.
230
+ 5. **Queries.** The `+` in the tab bar or the empty state opens a query tab.
231
+ Tabs survive a reload or an app restart: the open queries with their text,
232
+ the table tabs with their filter, ordering and Data/Structure view, plus the
233
+ active tab and the tab order, are stored per connection in the app's own
234
+ metadata database (not the target database) and restored when you open that
235
+ connection again. Closing a tab deletes it for good. Drag a tab to reorder
236
+ the strip, or focus it and press `Alt+Left` / `Alt+Right`. The editor has a
237
+ line-number gutter that scrolls with the code.
238
+ The editor is a resizable pane: drag the splitter under it, use
239
+ `ArrowUp`/`ArrowDown` on the splitter, or double-click it to reset. The height
240
+ is remembered per browser. Highlighting follows the active engine
241
+ (PostgreSQL, MySQL, SQLite or Redis) and needs no editor dependency.
242
+ The editor completes as you type: keywords and functions ranked by what the
243
+ caret expects, table and view names after `FROM` / `JOIN` / `INTO` /
244
+ `UPDATE`, schema (MySQL: database) names once the connection has more than
245
+ one, and column names bare, `alias.` or `table.` for the tables the statement
246
+ mentions. `Tab` accepts the highlighted row, `Enter` accepts it only while a
247
+ word is half typed, `Ctrl/Cmd+Space` opens the list and `Escape` closes it
248
+ without leaving the editor. Columns are fetched per table on demand and
249
+ dropped after a run, so `CREATE` / `ALTER` is reflected immediately.
250
+ `Ctrl/Cmd+Enter` runs the selection when there is one, otherwise the whole
251
+ buffer. Multiple `;`-separated statements each get a result
252
+ tab, with rows, affected counts and durations. Every run reports its outcome:
253
+ "Running query" while it is in flight, then a green "Query succeeded" strip
254
+ with statement, row and duration counts, or a red "Query failed" strip with
255
+ the server message and Retry. A matching status chip sits in the tab toolbar
256
+ and stays put after the strip is dismissed.
257
+ 6. **Redis.** Pick a Redis connection and browser mode opens: MATCH pattern,
258
+ type chips, keys grouped by prefix with TTLs, Load more for the next SCAN
259
+ page, per-type detail with paging, Rename / Set TTL / Delete, and a command
260
+ bar that prints readable results for nested replies.
261
+ 7. **Theme.** The title-bar toggle switches dark and light. The choice is kept in
262
+ `localStorage`.
263
+
264
+ ## Keyboard shortcuts
265
+
266
+ Every toolbar button advertises its chord in the hover title. `Ctrl/Cmd` is used
267
+ for app-wide actions so typing in a field never loses a character; `Alt` is used
268
+ for the actions of the panel that is on screen, and the panel owns them: while a
269
+ table tab is open `Alt+R` refreshes the table, otherwise it refreshes the tree.
270
+
271
+ | Action | Keys |
272
+ | --- | --- |
273
+ | Run query (selection, else everything) | `Ctrl/Cmd+Enter` |
274
+ | Complete the word under the caret | `Ctrl/Cmd+Space` |
275
+ | Jump to a table or view | `Ctrl/Cmd+K` |
276
+ | Show / hide the sidebar | `Ctrl/Cmd+B` |
277
+ | Switch dark / light | `Ctrl/Cmd+Shift+L` |
278
+ | Connections screen | `Alt+C` |
279
+ | New query / new connection | `Alt+N` / `Alt+Shift+N` |
280
+ | Close tab | `Alt+W` |
281
+ | Previous / next tab | `Alt+Shift+Left` / `Alt+Shift+Right` |
282
+ | Move the open tab | `Alt+Left` / `Alt+Right` |
283
+ | Data / Structure view | `Alt+1` / `Alt+2` |
284
+ | Row inspector | `Alt+I` |
285
+ | Refresh the current panel, or retry | `Alt+R` |
286
+ | Export the current grid (CSV) or the DDL | `Alt+S` |
287
+ | Copy DDL / copy the inspected row as JSON | `Alt+Shift+C` |
288
+ | Dismiss the query outcome strip | `Alt+Shift+D` |
289
+ | Previous / next page (table rows, Redis keys and entries) | `Alt+[` / `Alt+]` |
290
+ | Run command (Redis), apply filters, save and connect | `Alt+Enter` |
291
+ | Rename / Set TTL / Delete a Redis key | `Alt+M` / `Alt+T` / `Alt+Delete` |
292
+ | Test / save a connection | `Alt+T` / `Alt+S` |
293
+ | Close a dialog, cancel the connection form | `Esc` |
294
+
295
+ ## Tests
296
+
297
+ Backend (from the repo root):
298
+
299
+ ```bash
300
+ python -m pytest
301
+ ```
302
+
303
+ The suite covers the SQLite engine end to end, connection CRUD and validation,
304
+ table/query endpoints, workspace tab persistence, the Redis tokenizer and a
305
+ fakeredis-backed Redis engine. It runs against temporary databases and never
306
+ touches a real server.
307
+
308
+ Optional live engine checks create and drop one probe table in the configured
309
+ database, then disconnect:
310
+
311
+ ```bash
312
+ TEST_POSTGRES_DSN=postgresql://user:pass@127.0.0.1:5432/testdb python -m pytest -q
313
+ TEST_MYSQL_DSN=mysql://user:pass@127.0.0.1:3306/testdb python -m pytest -q
314
+ ```
315
+
316
+ Frontend (from `web/`):
317
+
318
+ ```bash
319
+ npm run check # svelte-check, zero warnings expected
320
+ npm test # vitest, pure helpers only
321
+ npm run build
322
+ ```
323
+
324
+ ## Package / PyPI
325
+
326
+ The wheel bundles the compiled UI and the SQL migrations, so one install serves
327
+ both the SPA and the API. `pip` puts a `db33studio` command on your `PATH`:
328
+
329
+ ```bash
330
+ python scripts/build_ui.py && python -m build --wheel # dist/db33studio-<version>-py3-none-any.whl
331
+
332
+ pip install db33studio
333
+ db33studio # then open http://127.0.0.1:2100
334
+ db33studio --help # --port 8080, or --debug for auto-reload
335
+ ```
336
+
337
+ It runs from any directory: the UI and the migrations are read from the
338
+ installed package, and the connection list lives in your per-user data
339
+ directory. `python -m db33studio` is the same entry point if you prefer it.
340
+
341
+ The Svelte source in `web/` is never part of the wheel: build the UI first, then
342
+ build the wheel. Distribution metadata (version, dependencies, console script)
343
+ lives in `pyproject.toml`, and the version comes from `db33studio.__version__`.
344
+
345
+ ## Supported operations and limitations
346
+
347
+ - **Raw SQL is intentional.** The `WHERE` and `ORDER BY` fields and the query
348
+ editor send SQL to the server verbatim. The app does not parse or sanitise
349
+ them. `UPDATE`, `DELETE`, `DROP` and friends will run, and there is no
350
+ transaction history or undo. Use a read-only connection where it matters.
351
+ - **Local single-user storage.** Saved connections and the open tabs of each
352
+ connection live in the app's own SQLite file in the per-user data directory
353
+ (`~/.local/share/db33studio/app.db` on Linux,
354
+ `%LOCALAPPDATA%\db33studio\app.db` on Windows,
355
+ `~/Library/Application Support/db33studio/app.db` on macOS), overridable with
356
+ `DATABASE_PATH`. There is no login, no sharing and no encryption. The backend
357
+ has no authentication; run it on localhost (`python -m db33studio --debug`)
358
+ unless you have put your own access control in front of it.
359
+ - **Passwords are stored in plaintext.** The password column in that database
360
+ file is not encrypted. The API never returns it (responses
361
+ expose `has_password` only) and the UI never renders it, but anyone who can
362
+ read that file can read the credentials. Prefer dedicated read-only database
363
+ users, and delete connections you no longer need.
364
+ - **Limits.** Query results are capped at 5000 rows; table pages at 1000 rows
365
+ (default 100); Redis scans and key detail pages at 1000 entries. Every
366
+ request has a 30 s budget by default (`QUERY_TIMEOUT_SECONDS`).
367
+ - **Identifiers versus values.** Schema and table names are validated against a
368
+ conservative pattern and quoted per dialect. Filter values must be written as
369
+ SQL literals by you, because the whole clause is raw.
370
+ - **Redis.** `SCAN` is used for key listing, so a pattern is not a `KEYS` scan
371
+ and type filtering happens after `TYPE` per key. Server administration is
372
+ blocked in the command bar: `CONFIG`, `SHUTDOWN`, `DEBUG`, `MONITOR`,
373
+ `SAVE`, `BGSAVE`, `FLUSHALL`, `FLUSHDB`, `MIGRATE`, `REPLICAOF`, `SLAVEOF`,
374
+ `ACL`, `MODULE`, `SCRIPT`, `EVAL`, `EVALSHA`, `FUNCTION`.
375
+ - **No schema editing.** This client reads and queries data; it does not create
376
+ or alter tables. Use a migration tool for that.
377
+ - **DDL fidelity.** PostgreSQL DDL is reconstructed from catalogs and is
378
+ readable but not byte-identical; if the catalogs are not readable by the
379
+ connected role, `ddl` is `null`. MySQL DDL comes from `SHOW CREATE TABLE`;
380
+ index sizes are not exposed and are `null`. SQLite DDL is the stored
381
+ `CREATE` statement.
382
+ - **Row counts.** Tree estimates are server statistics (PostgreSQL `reltuples`,
383
+ MySQL `TABLE_ROWS`), not exact. The grid footer comes from a real `COUNT(*)`
384
+ with the current filter.
385
+ - **Not included.** SSH tunnels, cloud IAM auth, schema diffs, import files,
386
+ saved query library, TLS client certificates, and multi-user access.
387
+
388
+ ## Screenshots
389
+
390
+ | | |
391
+ | --- | --- |
392
+ | ![New connection](docs/screenshots/new-connection-dark.png) | ![Table structure](docs/screenshots/table-structure-dark.png) |
393
+ | ![Query tab](docs/screenshots/query-dark.png) | ![Redis browser](docs/screenshots/redis-dark.png) |
394
+
395
+ | | |
396
+ | --- | --- |
397
+ | ![Table data, light theme](docs/screenshots/table-data-light.png) | ![Query tab, light theme](docs/screenshots/query-light.png) |
398
+
399
+ All screenshots are 1440x900 PNGs in [docs/screenshots](docs/screenshots).
400
+
401
+ ## License
402
+
403
+ Apache License 2.0. See [LICENSE](LICENSE).
404
+
405
+ Copyright 2026 hussein.