sqlalchemy-studio
FastAPI studio for inspecting and querying SQLAlchemy databases.
Installation
Install from PyPI:
pip install sqlalchemy-studio
Or install the latest version from GitHub:
pip install --upgrade git+https://github.com/coderxuz/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend
Usage
Create a normal SQLAlchemy engine and declarative base, then pass them to Studio.
from sqlalchemy import Integer, String, create_engine
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column
from sqlalchemy_studio import Studio
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
username: Mapped[str] = mapped_column(String(50), nullable=False)
email: Mapped[str] = mapped_column(String(120), nullable=False)
engine = create_engine("sqlite:///app.db")
def seed_data() -> None:
Base.metadata.create_all(engine)
with Session(engine) as session:
if session.query(User).count() == 0:
session.add_all(
[
User(username="john", email="john@example.com"),
User(username="alice", email="alice@example.com"),
]
)
session.commit()
if __name__ == "__main__":
seed_data()
Studio(engine=engine, base=Base, path="/studio").run(port=7000)
Run the script:
python app.py
Open http://localhost:7000 in your browser.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlalchemy_studio-0.2.0.tar.gz
(123.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlalchemy_studio-0.2.0.tar.gz.
File metadata
- Download URL: sqlalchemy_studio-0.2.0.tar.gz
- Upload date:
- Size: 123.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
061e220316a7230477d557d489e7e7d3dff1916ec367330a522600a25c6eb66f
|
|
| MD5 |
6fc89de2fb7650da41c46c97f452b4d4
|
|
| BLAKE2b-256 |
8f4a199c27de5e0acf8a0bc94c96f091fb0a5d2b35b85b8499a9f4c1768acb3e
|
File details
Details for the file sqlalchemy_studio-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy_studio-0.2.0-py3-none-any.whl
- Upload date:
- Size: 124.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8439e399a2c7f13752217ad1df0e16b6c913fd206767412bcabcd85be28455dc
|
|
| MD5 |
896f0c5b0d8968ebfe4090632c0367cb
|
|
| BLAKE2b-256 |
5954f2fb3a5750c2f718fd864c5b23cc1a544b8b33c8b4848d66a4b483d9079d
|