sqlalchemy-studio 0.1.0__tar.gz → 0.1.2__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlalchemy-studio
3
- Version: 0.1.0
4
- Summary: Add your description here
3
+ Version: 0.1.2
4
+ Summary: FastAPI studio for inspecting SQLAlchemy databases
5
5
  Author-email: Xursand Qarlibayev <coderxuz2009@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/coderxuz/sqlalchemy-studio
@@ -21,7 +21,7 @@ Requires-Dist: sqlalchemy>=2.0.50
21
21
  Requires-Dist: twine>=6.2.0
22
22
  Requires-Dist: uvicorn>=0.48.0
23
23
 
24
- # sqlalchemy-studio-backend
24
+ # sqlalchemy-studio
25
25
 
26
26
  Backend utilities for inspecting and serving database tables via a FastAPI `Studio`.
27
27
 
@@ -37,23 +37,25 @@ Quick summary
37
37
  Install
38
38
 
39
39
  ```
40
- pip install sqlalchemy-studio-backend
40
+ pip install sqlalchemy-studio
41
41
  ```
42
42
 
43
43
  Or install from the repository for development/testing:
44
44
 
45
45
  ```
46
- pip install --upgrade git+https://github.com/yourusername/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
46
+ pip install --upgrade git+https://github.com/coderxuz/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
47
47
  ```
48
48
 
49
49
  Quickstart
50
50
 
51
51
  ```py
52
52
  from sqlalchemy import create_engine
53
- from sqlalchemy.orm import declarative_base
54
- from db.main import Studio
53
+ from sqlalchemy.orm import DeclarativeBase
54
+ from sqlalchemy_studio import Studio
55
+
56
+ class Base(DeclarativeBase):
57
+ pass
55
58
 
56
- Base = declarative_base()
57
59
  engine = create_engine("sqlite:///test.db")
58
60
 
59
61
  studio = Studio(engine, Base)
@@ -64,7 +66,7 @@ studio.run(port=9000)
64
66
 
65
67
  Serving a built frontend (optional)
66
68
 
67
- If you build the Vite frontend, copy its `dist` output into the backend `static` folder
69
+ If you build the Vite frontend, copy its `dist` output into the backend `studio/static` folder
68
70
  and the backend will serve the SPA from `/` while keeping the API under `/api`.
69
71
 
70
72
  Example:
@@ -73,14 +75,14 @@ Example:
73
75
  # from repository root
74
76
  npm --prefix sqlalchemy-studio-front install
75
77
  npm --prefix sqlalchemy-studio-front run build
76
- rm -rf sqlalchemy-studio-backend/static
77
- mkdir -p sqlalchemy-studio-backend/static
78
- cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/static/
78
+ rm -rf sqlalchemy-studio-backend/studio/static
79
+ mkdir -p sqlalchemy-studio-backend/studio/static
80
+ cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/studio/static/
79
81
  ```
80
82
 
81
83
  Configuration notes
82
84
  - By default the package mounts static files at `/` and prefixes API routes with `/api` to
83
- avoid SPA route collisions. Adjust `db/main.py` if you need a different layout.
85
+ avoid SPA route collisions. Adjust `studio/Studio.py` if you need a different layout.
84
86
  - CORS: `Studio` registers a small set of development origins. When serving the SPA
85
87
  from the same server you won't need CORS; keep/update `Studio._set_cors` for other setups.
86
88
 
@@ -1,4 +1,4 @@
1
- # sqlalchemy-studio-backend
1
+ # sqlalchemy-studio
2
2
 
3
3
  Backend utilities for inspecting and serving database tables via a FastAPI `Studio`.
4
4
 
@@ -14,23 +14,25 @@ Quick summary
14
14
  Install
15
15
 
16
16
  ```
17
- pip install sqlalchemy-studio-backend
17
+ pip install sqlalchemy-studio
18
18
  ```
19
19
 
20
20
  Or install from the repository for development/testing:
21
21
 
22
22
  ```
23
- pip install --upgrade git+https://github.com/yourusername/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
23
+ pip install --upgrade git+https://github.com/coderxuz/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
24
24
  ```
25
25
 
26
26
  Quickstart
27
27
 
28
28
  ```py
29
29
  from sqlalchemy import create_engine
30
- from sqlalchemy.orm import declarative_base
31
- from db.main import Studio
30
+ from sqlalchemy.orm import DeclarativeBase
31
+ from sqlalchemy_studio import Studio
32
+
33
+ class Base(DeclarativeBase):
34
+ pass
32
35
 
33
- Base = declarative_base()
34
36
  engine = create_engine("sqlite:///test.db")
35
37
 
36
38
  studio = Studio(engine, Base)
@@ -41,7 +43,7 @@ studio.run(port=9000)
41
43
 
42
44
  Serving a built frontend (optional)
43
45
 
44
- If you build the Vite frontend, copy its `dist` output into the backend `static` folder
46
+ If you build the Vite frontend, copy its `dist` output into the backend `studio/static` folder
45
47
  and the backend will serve the SPA from `/` while keeping the API under `/api`.
46
48
 
47
49
  Example:
@@ -50,14 +52,14 @@ Example:
50
52
  # from repository root
51
53
  npm --prefix sqlalchemy-studio-front install
52
54
  npm --prefix sqlalchemy-studio-front run build
53
- rm -rf sqlalchemy-studio-backend/static
54
- mkdir -p sqlalchemy-studio-backend/static
55
- cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/static/
55
+ rm -rf sqlalchemy-studio-backend/studio/static
56
+ mkdir -p sqlalchemy-studio-backend/studio/static
57
+ cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/studio/static/
56
58
  ```
57
59
 
58
60
  Configuration notes
59
61
  - By default the package mounts static files at `/` and prefixes API routes with `/api` to
60
- avoid SPA route collisions. Adjust `db/main.py` if you need a different layout.
62
+ avoid SPA route collisions. Adjust `studio/Studio.py` if you need a different layout.
61
63
  - CORS: `Studio` registers a small set of development origins. When serving the SPA
62
64
  from the same server you won't need CORS; keep/update `Studio._set_cors` for other setups.
63
65
 
@@ -1,7 +1,11 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
1
5
  [project]
2
6
  name = "sqlalchemy-studio"
3
- version = "0.1.0"
4
- description = "Add your description here"
7
+ version = "0.1.2"
8
+ description = "FastAPI studio for inspecting SQLAlchemy databases"
5
9
  readme = "README.md"
6
10
  requires-python = ">=3.11"
7
11
  dependencies = [
@@ -25,3 +29,9 @@ classifiers = [
25
29
  "Programming Language :: Python :: 3.11",
26
30
  ]
27
31
  urls = { "Homepage" = "https://github.com/coderxuz/sqlalchemy-studio", "Source" = "https://github.com/coderxuz/sqlalchemy-studio" }
32
+
33
+ [tool.setuptools.packages.find]
34
+ include = ["studio*", "sqlalchemy_studio*"]
35
+
36
+ [tool.setuptools.package-data]
37
+ studio = ["static/**/*"]
@@ -4,10 +4,11 @@ from sqlalchemy.orm import DeclarativeBase
4
4
  from fastapi import FastAPI, HTTPException, status
5
5
  from fastapi.middleware.cors import CORSMiddleware
6
6
  from fastapi.staticfiles import StaticFiles
7
+ from importlib.resources import files
7
8
  import uvicorn
8
9
 
9
10
 
10
- from studio .backend import create_tables_router
11
+ from studio.backend import create_tables_router
11
12
 
12
13
  from typing import Self, TypedDict, Any, cast, TYPE_CHECKING
13
14
 
@@ -70,7 +71,13 @@ class Studio:
70
71
 
71
72
  def _register_routes(self):
72
73
  self.app.include_router(create_tables_router(self))
73
- self.app.mount("/", StaticFiles(directory="./studio/static", html=True), name="static")
74
+ static_dir = files("studio").joinpath("static")
75
+ if static_dir.is_dir():
76
+ self.app.mount(
77
+ "/",
78
+ StaticFiles(directory=str(static_dir), html=True),
79
+ name="static",
80
+ )
74
81
 
75
82
  def run(self, port: int = 8000):
76
83
  print("-"*50)
@@ -0,0 +1,3 @@
1
+ from sqlalchemy_studio.Studio import Studio
2
+
3
+ __all__ = ["Studio"]
@@ -1,9 +1,9 @@
1
- from fastapi import APIRouter, Query, HTTPException,status
1
+ from fastapi import APIRouter, HTTPException, status
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
5
  if TYPE_CHECKING:
6
- from backend.Studio import Studio
6
+ from studio.Studio import Studio
7
7
 
8
8
  from typing import Any, Literal, Self, TypedDict
9
9
  from pydantic import BaseModel, Field
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlalchemy-studio
3
- Version: 0.1.0
4
- Summary: Add your description here
3
+ Version: 0.1.2
4
+ Summary: FastAPI studio for inspecting SQLAlchemy databases
5
5
  Author-email: Xursand Qarlibayev <coderxuz2009@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/coderxuz/sqlalchemy-studio
@@ -21,7 +21,7 @@ Requires-Dist: sqlalchemy>=2.0.50
21
21
  Requires-Dist: twine>=6.2.0
22
22
  Requires-Dist: uvicorn>=0.48.0
23
23
 
24
- # sqlalchemy-studio-backend
24
+ # sqlalchemy-studio
25
25
 
26
26
  Backend utilities for inspecting and serving database tables via a FastAPI `Studio`.
27
27
 
@@ -37,23 +37,25 @@ Quick summary
37
37
  Install
38
38
 
39
39
  ```
40
- pip install sqlalchemy-studio-backend
40
+ pip install sqlalchemy-studio
41
41
  ```
42
42
 
43
43
  Or install from the repository for development/testing:
44
44
 
45
45
  ```
46
- pip install --upgrade git+https://github.com/yourusername/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
46
+ pip install --upgrade git+https://github.com/coderxuz/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
47
47
  ```
48
48
 
49
49
  Quickstart
50
50
 
51
51
  ```py
52
52
  from sqlalchemy import create_engine
53
- from sqlalchemy.orm import declarative_base
54
- from db.main import Studio
53
+ from sqlalchemy.orm import DeclarativeBase
54
+ from sqlalchemy_studio import Studio
55
+
56
+ class Base(DeclarativeBase):
57
+ pass
55
58
 
56
- Base = declarative_base()
57
59
  engine = create_engine("sqlite:///test.db")
58
60
 
59
61
  studio = Studio(engine, Base)
@@ -64,7 +66,7 @@ studio.run(port=9000)
64
66
 
65
67
  Serving a built frontend (optional)
66
68
 
67
- If you build the Vite frontend, copy its `dist` output into the backend `static` folder
69
+ If you build the Vite frontend, copy its `dist` output into the backend `studio/static` folder
68
70
  and the backend will serve the SPA from `/` while keeping the API under `/api`.
69
71
 
70
72
  Example:
@@ -73,14 +75,14 @@ Example:
73
75
  # from repository root
74
76
  npm --prefix sqlalchemy-studio-front install
75
77
  npm --prefix sqlalchemy-studio-front run build
76
- rm -rf sqlalchemy-studio-backend/static
77
- mkdir -p sqlalchemy-studio-backend/static
78
- cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/static/
78
+ rm -rf sqlalchemy-studio-backend/studio/static
79
+ mkdir -p sqlalchemy-studio-backend/studio/static
80
+ cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/studio/static/
79
81
  ```
80
82
 
81
83
  Configuration notes
82
84
  - By default the package mounts static files at `/` and prefixes API routes with `/api` to
83
- avoid SPA route collisions. Adjust `db/main.py` if you need a different layout.
85
+ avoid SPA route collisions. Adjust `studio/Studio.py` if you need a different layout.
84
86
  - CORS: `Studio` registers a small set of development origins. When serving the SPA
85
87
  from the same server you won't need CORS; keep/update `Studio._set_cors` for other setups.
86
88
 
@@ -1,10 +1,10 @@
1
1
  README.md
2
2
  pyproject.toml
3
+ sqlalchemy_studio/Studio.py
4
+ sqlalchemy_studio/__init__.py
5
+ sqlalchemy_studio/backend.py
3
6
  sqlalchemy_studio.egg-info/PKG-INFO
4
7
  sqlalchemy_studio.egg-info/SOURCES.txt
5
8
  sqlalchemy_studio.egg-info/dependency_links.txt
6
9
  sqlalchemy_studio.egg-info/requires.txt
7
- sqlalchemy_studio.egg-info/top_level.txt
8
- studio/Studio.py
9
- studio/__init__.py
10
- studio/backend.py
10
+ sqlalchemy_studio.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ sqlalchemy_studio
@@ -1 +0,0 @@
1
- from studio.Studio import Studio