DEV Community

hungle00
hungle00

Posted on

SQLite Opus β€” Web-Based SQLite Browser for Flask

Hello everyone! I’ve just published my first package on PyPI called sqlite-opus πŸŽ‰. It’s a lightweight tool designed to help you run SQLite queries and manage your database through a web-based UI.

What does sqlite-opus offer?

  • Database connection management β€” Connect to and disconnect from SQLite files
  • Web-based SQL query interface β€” Run queries from the browser and see the results
  • Table schema viewer β€” Explore table structures, including columns, data types, and indexes.
  • Export CSV β€” Export query results to CSV files

Sqlite Opus demo

How is sqlite-opus different from other tools like sqlite-web?

Tools like sqlite-web work great as standalone database browsers. sqlite-opus, on the other hand, focuses on simplicity and easy integration. It is built to live inside your existing Flask app instead of a separate service. With sqlite-opus, you only need to install it in your Flask project to start querying your database directly from the browser.

Installation and Usage

Install from PyPI:

pip install sqlite-opus
Enter fullscreen mode Exit fullscreen mode

After installation, you can bind the dashboard to your project and run it.

from flask import Flask
import sqlite_opus as dashboard

app = Flask(__name__)

# Bind the dashboard to your Flask app
dashboard.bind(app)

# Dashboard is available at http://localhost:5000/sqlite-opus
app.run()
Enter fullscreen mode Exit fullscreen mode

That’s it. Open http://localhost:5000/sqlite-opus, connect to a SQLite file (e.g. ./mydb.sqlite3), and start browsing tables and running queries.

sqlite-opus comes with optional configuration that you can set before or during bind():

import sqlite_opus as dashboard

# Option 1: Configure before binding
dashboard.config.url_prefix = "my-dashboard"
dashboard.config.max_query_results = 500
dashboard.config.db_path = "db.sqlite3"   # Pre-configured DB (auto-connect)
dashboard.config.auth_user = "admin"
dashboard.config.auth_password = "secret"
dashboard.config.allow_dml = True         # Allow INSERT/UPDATE/DELETE
dashboard.bind(app)

# Option 2: Configure during binding
dashboard.bind(
    app,
    url_prefix="my-dashboard",
    max_query_results=500,
    enable_cors=True,
)
Enter fullscreen mode Exit fullscreen mode

Security (development vs production): For a more secure setup in production, use Basic Auth and keep allow_dml disabled (read-only). For example:

dashboard.bind(
    app,
    auth_user="admin",
    auth_password="your-strong-password",
    allow_dml=False,  # read-only; no INSERT/UPDATE/DELETE
    db_path="data.db",
)
Enter fullscreen mode Exit fullscreen mode

In development you can omit auth or set allow_dml=True if you need to run write queries from the dashboard.

More details are in the repo: https://github.com/hungle00/sqlite-opus


I’m planning to keep improving sqlite-opus with features like query history, better UI/UX, and support for connecting to multiple databases.

Feedback, suggestions, and contributions are always welcome. I’d love to hear what you think! πŸš€

Top comments (0)