Skip to main content

ashurbanipal-flask

A read-only database browser you mount inside your own Flask app. It connects with your app's database settings, so there are no extra credentials and nothing extra to deploy. Part of Ashurbanipal.

Requires Python 3.12+ and Flask 3.

Install

Pick the extra for your database:

uv add 'ashurbanipal-flask[postgres]'   # or: pip install 'ashurbanipal-flask[postgres]'
uv add 'ashurbanipal-flask[mysql]'      # MySQL or MariaDB
uv add ashurbanipal-flask               # SQLite needs no extra

Quick start

import os

from flask import Flask

from ashurbanipal import Config, router
from ashurbanipal.db.postgres import PgSource

app = Flask(__name__)
# your own routes

config = Config(enabled=True)
source = PgSource(dsn=os.environ["DATABASE_URL"])
app.register_blueprint(router(config, [("primary", source)]))

Run flask run and open http://localhost:5000/__ashurbanipal.

Turn it on only where you want it

enabled defaults to False. When it is off, every viewer path returns 404. Decide where to enable it, for example from an environment variable:

config = Config(enabled=os.environ.get("ASHURBANIPAL_ENABLED") == "true")

Protect it

Ashurbanipal has no login. Anyone who can reach /__ashurbanipal can read every table your app's database user can read. Put your own auth in front, and check a role, not just a login. router() returns a blueprint, so a hook on it covers only the viewer:

from flask import abort

bp = router(config, [("primary", source)])


@bp.before_request
def require_admin():
    if not is_admin():
        abort(401)


app.register_blueprint(bp)

A hook on the blueprint follows it to any mount path you choose, and checks only the viewer's own routes, never yours. A root mount (mount="/", or url_prefix="/" at registration) raises ValueError, because it would take / and /api/... from your app.

MySQL, MariaDB, or SQLite

from ashurbanipal.db.mysql import MySqlSource, connect_kwargs_from_url

source = MySqlSource(**connect_kwargs_from_url(os.environ["MYSQL_URL"]))  # mysql://user:pass@host:3306/db

MySqlSource also takes pymysql.connect() keyword arguments directly, for example MySqlSource(host="localhost", user="app", password="...", database="app").

from ashurbanipal.db.sqlite import SqliteSource

source = SqliteSource(path="app.db")

SQLite needs a real file. :memory: does not work, because each request opens a new connection and sees an empty database. To open the file read-only, pass a URI: SqliteSource(path="file:app.db?mode=ro").

Column comments are empty on SQLite, and common-value stats are empty on MySQL and SQLite.

More than one database

Pass more than one source. The first one is the default, and the UI lets you switch between them:

router(
    config,
    [
        ("orders", PgSource(dsn=os.environ["ORDERS_DATABASE_URL"])),
        ("billing", PgSource(dsn=os.environ["BILLING_DATABASE_URL"])),
    ],
)

Connections

Each request opens its own database connection and closes it at the end. There is no pool. For pooling, write your own DbSource around your pool.

Configuration

from ashurbanipal import Config, Limits

config = Config(
    enabled=True,
    limits=Limits(default_page_size=50, max_page_size=100, query_timeout_secs=5),  # optional; the defaults
)

app.register_blueprint(router(config, sources, mount="/__ashurbanipal"))  # optional mount; never /

The configuration table lists every option, including instance and siblings. Those let the UI show which of your other services are reachable. Import Instance and Sibling from ashurbanipal. Set allowed_hosts to the names the viewer is reached at, so a DNS-rebinding page can't read it; without it, router() logs a warning on the ashurbanipal.routes logger.

See also

Metadata

Release files for ashurbanipal-flask 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ashurbanipal-flask 0.16.0
File Size Uploaded Provenance Actions
ashurbanipal_flask-0.16.0.tar.gz 213.9 kB With provenance Details for ashurbanipal_flask-0.16.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ashurbanipal-flask 0.16.0
File Interpreter ABI Platform Actions
ashurbanipal_flask-0.16.0-py3-none-any.whl Python 3 none any Details for ashurbanipal_flask-0.16.0-py3-none-any.whl

Total release size: 363.3 kB

Release files / ashurbanipal_flask-0.16.0.tar.gz

Download URL ashurbanipal_flask-0.16.0.tar.gz
Size 213.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2d19346e39178cc14c17944e109bfbdb585e866adb9697dbfc70731b386701bf
BLAKE2b-256 checksum
How to use checksums
a520335b691d54815f0c977bdc5eb02af00dda4c90eab56bc8247858a7e9c3c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / ashurbanipal_flask-0.16.0-py3-none-any.whl

Download URL ashurbanipal_flask-0.16.0-py3-none-any.whl
Size 149.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5eb8e2d26af9c3db78277c281a45cc36d2122fb87b8a34d840a02451765ced11
BLAKE2b-256 checksum
How to use checksums
c1ae43ac1155f7c966c51d11ccd47d5ffe7811d8b8e2931b02efac9a2d0a7297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for ashurbanipal-flask 0.16.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ashurbanipal_flask-0.16.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page