sqlite-webpanel 0.1.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.
- sqlite_webpanel-0.1.0/LICENSE +21 -0
- sqlite_webpanel-0.1.0/PKG-INFO +157 -0
- sqlite_webpanel-0.1.0/README.md +123 -0
- sqlite_webpanel-0.1.0/pyproject.toml +60 -0
- sqlite_webpanel-0.1.0/setup.cfg +4 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/__init__.py +23 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/db.py +360 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/mount.py +97 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/renderers.py +119 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/router.py +245 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/static/panel.css +1000 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/static/panel.js +407 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/base.html +71 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/empty.html +8 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/partials/rows.html +120 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/redirect.html +9 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/row_detail.html +56 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel/templates/table.html +133 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel.egg-info/PKG-INFO +157 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel.egg-info/SOURCES.txt +24 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel.egg-info/dependency_links.txt +1 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel.egg-info/requires.txt +10 -0
- sqlite_webpanel-0.1.0/src/sqlite_webpanel.egg-info/top_level.txt +1 -0
- sqlite_webpanel-0.1.0/tests/test_db.py +194 -0
- sqlite_webpanel-0.1.0/tests/test_renderers.py +76 -0
- sqlite_webpanel-0.1.0/tests/test_router.py +164 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 sqlite-panel contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sqlite_webpanel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A plug-and-play SQLite admin panel for FastAPI — beautiful, fast, and intelligent by default.
|
|
5
|
+
Author: Purva Sanjay Patel
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/purvaspatel
|
|
8
|
+
Project-URL: Documentation, https://github.com/purvaspatel/sqlite-webpanel#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/purvaspatel/sqlit_webpanel
|
|
10
|
+
Keywords: sqlite,fastapi,admin,panel,database
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Framework :: FastAPI
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Database
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: fastapi>=0.100.0
|
|
25
|
+
Requires-Dist: jinja2>=3.1.0
|
|
26
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
27
|
+
Requires-Dist: uvicorn>=0.22.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
31
|
+
Requires-Dist: httpx>=0.24; extra == "dev"
|
|
32
|
+
Requires-Dist: uvicorn>=0.22; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# sqlite-panel
|
|
36
|
+
|
|
37
|
+
> A plug-and-play SQLite admin panel for FastAPI — beautiful, fast, and intelligent by default.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+

|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **One-line mount** — works with any FastAPI app
|
|
48
|
+
- **Auto-discovery** — detects all tables and columns automatically
|
|
49
|
+
- **Smart cell rendering** — JSON formatting, inline image previews, boolean badges, long text expand/collapse, file & URL links
|
|
50
|
+
- **Pagination, sorting, filtering, search** — all built-in
|
|
51
|
+
- **Inline editing** — double-click any cell to edit in place
|
|
52
|
+
- **Real-time change detection** — toast notifications + auto-refresh when the DB changes
|
|
53
|
+
- **Read-only mode** — disable all writes with a single flag
|
|
54
|
+
- **Light & dark mode** — with smooth toggle and `localStorage` persistence
|
|
55
|
+
- **Keyboard shortcuts** — `/` to search, `n` for new row, `Esc` to close modals
|
|
56
|
+
- **SQL injection safe** — all user input is parameterised or strictly validated
|
|
57
|
+
- **Zero heavy dependencies** — HTMX for partial refreshes, vanilla JS, Geist font via Google Fonts
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install sqlite_webpanel
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick start
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
|
|
71
|
+
from sqlite_webpanel import run_panel
|
|
72
|
+
run_panel(app, db_path="app.db")
|
|
73
|
+
# → Visit http://localhost:8888/admin
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Usage example
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# dbview.py
|
|
82
|
+
from sqlite_webpanel import run_panel
|
|
83
|
+
import sqlite3
|
|
84
|
+
|
|
85
|
+
app = FastAPI()
|
|
86
|
+
|
|
87
|
+
# Create some demo data
|
|
88
|
+
conn = sqlite3.connect("demo.db")
|
|
89
|
+
conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
|
|
90
|
+
conn.execute("INSERT OR IGNORE INTO users VALUES (1,'Alice','alice@example.com')")
|
|
91
|
+
conn.commit()
|
|
92
|
+
conn.close()
|
|
93
|
+
|
|
94
|
+
run_panel(db_path="demo.db", title="Demo DB")
|
|
95
|
+
|
|
96
|
+
# uvicorn main:app --reload
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
git clone https://github.com/yourname/sqlite_webpanel
|
|
105
|
+
cd sqlite_webpanel
|
|
106
|
+
pip install -e ".[dev]"
|
|
107
|
+
pytest
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Architecture
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
sqlite_panel/
|
|
116
|
+
├── __init__.py # Public API: mount_sqlite_panel
|
|
117
|
+
├── mount.py # FastAPI mounting + static files
|
|
118
|
+
├── router.py # All HTTP endpoints (web layer)
|
|
119
|
+
├── db.py # Core DB logic (pure Python, no web deps)
|
|
120
|
+
├── renderers.py # Smart cell → HTML conversion
|
|
121
|
+
├── static/
|
|
122
|
+
│ ├── panel.css # All styles (CSS variables, light/dark)
|
|
123
|
+
│ └── panel.js # Interactivity (vanilla JS)
|
|
124
|
+
└── templates/
|
|
125
|
+
├── base.html # Layout with sidebar
|
|
126
|
+
├── table.html # Table view with toolbar
|
|
127
|
+
├── row_detail.html
|
|
128
|
+
├── empty.html
|
|
129
|
+
├── redirect.html
|
|
130
|
+
└── partials/
|
|
131
|
+
└── rows.html # HTMX partial for table body
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Key design decisions:**
|
|
135
|
+
|
|
136
|
+
- `db.py` has zero FastAPI/web imports — testable in isolation
|
|
137
|
+
- `renderers.py` has zero DB imports — pure value → HTML transformation
|
|
138
|
+
- All SQL uses parameterised queries or `_safe_identifier()` validation
|
|
139
|
+
- HTMX partial endpoints allow row refresh without full page reload
|
|
140
|
+
- Change detection via polling `/api/fingerprint` (row count hash)
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Keyboard shortcuts
|
|
145
|
+
|
|
146
|
+
| Key | Action |
|
|
147
|
+
|-----|--------|
|
|
148
|
+
| `/` | Focus search |
|
|
149
|
+
| `n` | Open "New Row" modal |
|
|
150
|
+
| `Esc` | Close modal / cancel edit |
|
|
151
|
+
| Double-click cell | Inline edit |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# sqlite-panel
|
|
2
|
+
|
|
3
|
+
> A plug-and-play SQLite admin panel for FastAPI — beautiful, fast, and intelligent by default.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **One-line mount** — works with any FastAPI app
|
|
14
|
+
- **Auto-discovery** — detects all tables and columns automatically
|
|
15
|
+
- **Smart cell rendering** — JSON formatting, inline image previews, boolean badges, long text expand/collapse, file & URL links
|
|
16
|
+
- **Pagination, sorting, filtering, search** — all built-in
|
|
17
|
+
- **Inline editing** — double-click any cell to edit in place
|
|
18
|
+
- **Real-time change detection** — toast notifications + auto-refresh when the DB changes
|
|
19
|
+
- **Read-only mode** — disable all writes with a single flag
|
|
20
|
+
- **Light & dark mode** — with smooth toggle and `localStorage` persistence
|
|
21
|
+
- **Keyboard shortcuts** — `/` to search, `n` for new row, `Esc` to close modals
|
|
22
|
+
- **SQL injection safe** — all user input is parameterised or strictly validated
|
|
23
|
+
- **Zero heavy dependencies** — HTMX for partial refreshes, vanilla JS, Geist font via Google Fonts
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install sqlite_webpanel
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
|
|
37
|
+
from sqlite_webpanel import run_panel
|
|
38
|
+
run_panel(app, db_path="app.db")
|
|
39
|
+
# → Visit http://localhost:8888/admin
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Usage example
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# dbview.py
|
|
48
|
+
from sqlite_webpanel import run_panel
|
|
49
|
+
import sqlite3
|
|
50
|
+
|
|
51
|
+
app = FastAPI()
|
|
52
|
+
|
|
53
|
+
# Create some demo data
|
|
54
|
+
conn = sqlite3.connect("demo.db")
|
|
55
|
+
conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
|
|
56
|
+
conn.execute("INSERT OR IGNORE INTO users VALUES (1,'Alice','alice@example.com')")
|
|
57
|
+
conn.commit()
|
|
58
|
+
conn.close()
|
|
59
|
+
|
|
60
|
+
run_panel(db_path="demo.db", title="Demo DB")
|
|
61
|
+
|
|
62
|
+
# uvicorn main:app --reload
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Development
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/yourname/sqlite_webpanel
|
|
71
|
+
cd sqlite_webpanel
|
|
72
|
+
pip install -e ".[dev]"
|
|
73
|
+
pytest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Architecture
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
sqlite_panel/
|
|
82
|
+
├── __init__.py # Public API: mount_sqlite_panel
|
|
83
|
+
├── mount.py # FastAPI mounting + static files
|
|
84
|
+
├── router.py # All HTTP endpoints (web layer)
|
|
85
|
+
├── db.py # Core DB logic (pure Python, no web deps)
|
|
86
|
+
├── renderers.py # Smart cell → HTML conversion
|
|
87
|
+
├── static/
|
|
88
|
+
│ ├── panel.css # All styles (CSS variables, light/dark)
|
|
89
|
+
│ └── panel.js # Interactivity (vanilla JS)
|
|
90
|
+
└── templates/
|
|
91
|
+
├── base.html # Layout with sidebar
|
|
92
|
+
├── table.html # Table view with toolbar
|
|
93
|
+
├── row_detail.html
|
|
94
|
+
├── empty.html
|
|
95
|
+
├── redirect.html
|
|
96
|
+
└── partials/
|
|
97
|
+
└── rows.html # HTMX partial for table body
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Key design decisions:**
|
|
101
|
+
|
|
102
|
+
- `db.py` has zero FastAPI/web imports — testable in isolation
|
|
103
|
+
- `renderers.py` has zero DB imports — pure value → HTML transformation
|
|
104
|
+
- All SQL uses parameterised queries or `_safe_identifier()` validation
|
|
105
|
+
- HTMX partial endpoints allow row refresh without full page reload
|
|
106
|
+
- Change detection via polling `/api/fingerprint` (row count hash)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Keyboard shortcuts
|
|
111
|
+
|
|
112
|
+
| Key | Action |
|
|
113
|
+
|-----|--------|
|
|
114
|
+
| `/` | Focus search |
|
|
115
|
+
| `n` | Open "New Row" modal |
|
|
116
|
+
| `Esc` | Close modal / cancel edit |
|
|
117
|
+
| Double-click cell | Inline edit |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.setuptools.package-data]
|
|
6
|
+
sqlite_webpanel = [
|
|
7
|
+
"static/*",
|
|
8
|
+
"templates/*",
|
|
9
|
+
"templates/partials/*",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[tool.setuptools.packages.find]
|
|
13
|
+
where = ["src"]
|
|
14
|
+
include = ["sqlite_webpanel*"]
|
|
15
|
+
|
|
16
|
+
[tool.pytest.ini_options]
|
|
17
|
+
asyncio_mode = "auto"
|
|
18
|
+
testpaths = ["tests"]
|
|
19
|
+
|
|
20
|
+
[project]
|
|
21
|
+
name = "sqlite_webpanel"
|
|
22
|
+
version = "0.1.0"
|
|
23
|
+
description = "A plug-and-play SQLite admin panel for FastAPI — beautiful, fast, and intelligent by default."
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
license = "MIT"
|
|
26
|
+
license-files = ["LICENSE"]
|
|
27
|
+
authors = [{ name = "Purva Sanjay Patel" }]
|
|
28
|
+
keywords = ["sqlite", "fastapi", "admin", "panel", "database"]
|
|
29
|
+
classifiers = [
|
|
30
|
+
"Development Status :: 4 - Beta",
|
|
31
|
+
"Framework :: FastAPI",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.9",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Topic :: Database",
|
|
39
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
40
|
+
]
|
|
41
|
+
requires-python = ">=3.9"
|
|
42
|
+
dependencies = [
|
|
43
|
+
"fastapi>=0.100.0",
|
|
44
|
+
"jinja2>=3.1.0",
|
|
45
|
+
"python-multipart>=0.0.6",
|
|
46
|
+
"uvicorn>=0.22.0",
|
|
47
|
+
]
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
dev = [
|
|
50
|
+
"pytest>=7.0",
|
|
51
|
+
"pytest-asyncio>=0.21",
|
|
52
|
+
"httpx>=0.24",
|
|
53
|
+
"uvicorn>=0.22",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/purvaspatel"
|
|
58
|
+
Documentation = "https://github.com/purvaspatel/sqlite-webpanel#readme"
|
|
59
|
+
Repository = "https://github.com/purvaspatel/sqlit_webpanel"
|
|
60
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
sqlite_webpanel: A plug-and-play SQLite admin panel for FastAPI.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from sqlite_webpanel import mount_sqlite_panel, Database, _safe_identifier
|
|
6
|
+
|
|
7
|
+
mount_sqlite_panel(app, db_path="app.db")
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .mount import mount_sqlite_panel, run_panel
|
|
11
|
+
from .db import Database, _safe_identifier
|
|
12
|
+
from .renderers import render_cell
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"mount_sqlite_panel",
|
|
16
|
+
"Database",
|
|
17
|
+
"_safe_identifier",
|
|
18
|
+
"render_cell",
|
|
19
|
+
"run_panel"
|
|
20
|
+
# add other things you want exposed
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
__version__ = "0.1.0"
|