Skip to main content

FastAPI studio for inspecting SQLAlchemy databases

Project description

sqlalchemy-studio

Backend utilities for inspecting and serving database tables via a FastAPI Studio.

This package exposes a small FastAPI app that can be embedded in your application or run standalone to inspect a SQLAlchemy-accessible database.

Quick summary

  • API endpoints (when using the packaged server):
    • GET /api/tables — list tables and columns
    • GET /api/tables/{name} — describe a single table
    • POST /api/{table_name}/query — run the UI's advanced query payload

Install

pip install sqlalchemy-studio

Or install from the repository for development/testing:

pip install --upgrade git+https://github.com/coderxuz/sqlalchemy-studio.git@main#subdirectory=sqlalchemy-studio-backend

Quickstart

from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy_studio import Studio

class Base(DeclarativeBase):
    pass

engine = create_engine("sqlite:///test.db")

studio = Studio(engine, Base)
# Starts uvicorn and serves API under /api
studio.run(port=9000)
# API available at http://localhost:9000/api

Serving a built frontend (optional)

If you build the Vite frontend, copy its dist output into the backend studio/static folder and the backend will serve the SPA from / while keeping the API under /api.

Example:

# from repository root
npm --prefix sqlalchemy-studio-front install
npm --prefix sqlalchemy-studio-front run build
rm -rf sqlalchemy-studio-backend/studio/static
mkdir -p sqlalchemy-studio-backend/studio/static
cp -r sqlalchemy-studio-front/dist/* sqlalchemy-studio-backend/studio/static/

Configuration notes

  • By default the package mounts static files at / and prefixes API routes with /api to avoid SPA route collisions. Adjust studio/Studio.py if you need a different layout.
  • CORS: Studio registers a small set of development origins. When serving the SPA from the same server you won't need CORS; keep/update Studio._set_cors for other setups.

Publishing

  1. Build the distribution locally:
python -m pip install --upgrade build twine
python -m build
  1. Upload to PyPI (CI should set PYPI_API_TOKEN):
python -m twine upload dist/*

License MIT — update as appropriate.

Project details


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.1.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_studio-0.1.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_studio-0.1.3.tar.gz.

File metadata

  • Download URL: sqlalchemy_studio-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for sqlalchemy_studio-0.1.3.tar.gz
Algorithm Hash digest
SHA256 93717fc2fc0f62f5ea556069f84029d51c7c60f97b373bc7bf6967644bb5de83
MD5 ae524dceb1398cd5b5c21f362deba933
BLAKE2b-256 02933b76c4334ba73e496c5c20591b1cc4be2985e014343df191b4474fb9e1f0

See more details on using hashes here.

File details

Details for the file sqlalchemy_studio-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_studio-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b1f747d6d831800860ac1a9f2441b740b123ca82f04ae6b3d5b63408ac3c1c7
MD5 42d6150bc513f73af5e620973d2e4b8d
BLAKE2b-256 9bbde12f04a73a9bcb99b88ff9d77aced3c31f4eab7dc9a92f0978479d3959c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page