FastAPI studio for inspecting SQLAlchemy databases
Project description
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).run(port=7000)
Run the script:
python app.py
Open http://localhost:7000 in your browser.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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.1.8.tar.gz.
File metadata
- Download URL: sqlalchemy_studio-0.1.8.tar.gz
- Upload date:
- Size: 121.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
374d28138e8ea62e0f0b1b2669dcfe8e71c5f602d0695719907aeef4df92f604
|
|
| MD5 |
46a68cc404be0bd06cb32c470e10c718
|
|
| BLAKE2b-256 |
e4d99195e73add5f23fc0d8e8bedc0445fa3a24e24387d455ffca61cc5272943
|
File details
Details for the file sqlalchemy_studio-0.1.8-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy_studio-0.1.8-py3-none-any.whl
- Upload date:
- Size: 122.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 |
5e75c5a76f91870e9a14c046fbd87c6c974bafaae45a2a4c478fe73f8cedf3b8
|
|
| MD5 |
0e9f84d5b48b18c700ccc33fe25efc03
|
|
| BLAKE2b-256 |
9f0662b8f8b25e9f38b8821f93fdf00106da3ba0bf06e92f913d4b4e41e9cb51
|