MesaHub Python SDK
Python SDK for MesaHub — access SQLite databases from Python with raw SQL or a high-level table API.
Installation
pip install mesahub
Requires Python 3.11+ and httpx.
Quick Start
from mesahub import MesahubClient
client = MesahubClient(
api_key="shs_your_api_key", # from mesahub.app → Settings → API Keys
api_url="https://api.mesahub.app", # or your self-hosted core URL
)
db = client.db("my-app-db") # your database slug from the dashboard
users = db.table("users")
# High-level table API
all_rows = users.find(where={"active": 1}, limit=20)
alice = users.find_one(where={"email": "alice@example.com"})
count = users.count(where={"active": 1})
new_row = users.insert({"name": "Bob", "email": "bob@example.com", "active": 1})
users.update(where={"id": new_row["id"]}, set={"name": "Robert"})
users.delete(where={"id": new_row["id"]})
# Raw SQL
result = db.query("SELECT * FROM users WHERE active = ?", [1])
print(result["rows"]) # [{"id": 1, "name": "Alice", ...}]
db.exec("CREATE TABLE IF NOT EXISTS logs (msg TEXT, created_at TEXT)")
client.close()
Context manager
with MesahubClient(api_key="shs_...", api_url="https://api.mesahub.app") as client:
db = client.db("my-app-db")
rows = db.table("orders").find(where={"status": "pending"})
Connection String
from mesahub import MesahubClient, parse_mesahub_url
info = parse_mesahub_url("mh://shs_abc@mycore.railway.app/mydb")
client = MesahubClient(
api_key=info["api_key"],
api_url=info["api_url"],
route_prefix=info["route_prefix"],
)
db = client.db(info["db_name"])
Format: mh://apikey@host[:port]/dbname
- Remote hosts (e.g.
railway.app) → HTTPS,/v1/routes localhost/ Docker service names /*.internal→ HTTP,/api/routes
WHERE Filters
# Shorthand equality
users.find(where={"active": 1})
# Comparison operators
users.find(where={"age": {"gte": 18}, "score": {"lt": 100}})
# LIKE
users.find(where={"name": {"like": "%alice%"}})
# IN / NOT IN
users.find(where={"role": {"in": ["admin", "editor"]}})
# NULL checks
users.find(where={"deleted_at": {"is_null": True}})
users.find(where={"verified_at": {"is_not_null": True}})
All conditions in a single where dict are combined with AND.
| Operator key | SQL equivalent |
|---|---|
| (plain value) | = ? |
eq |
= ? |
ne |
!= ? |
gt |
> ? |
gte |
>= ? |
lt |
< ? |
lte |
<= ? |
like |
LIKE ? |
not_like |
NOT LIKE ? |
in |
IN (...) |
not_in |
NOT IN (...) |
is_null |
IS NULL |
is_not_null |
IS NOT NULL |
find() Options
users.find(
where={"active": 1},
select=["id", "name", "email"],
order_by=[{"column": "created_at", "direction": "desc"}],
limit=10,
offset=20,
)
insert_many()
db.table("logs").insert_many(
[{"msg": "started"}, {"msg": "done"}],
on_conflict="ignore", # "ignore" | "replace" | None
)
Files
files = db.files
# List
listing = files.list(limit=10, folder_prefix="reports/")
# Upload
record = files.upload(open("report.pdf", "rb").read(), "report.pdf", "application/pdf")
print(record["url"])
# Download
data = files.download(record["id"])
# Delete
files.delete(record["id"])
Error Handling
from mesahub import MesahubError, AuthenticationError, NotFoundError
try:
db.query("SELECT * FROM users")
except AuthenticationError:
print("Invalid API key")
except MesahubError as e:
print(f"[{e.code}] {e.status_code}: {e}")
Self-Hosting
Replace api_url with your own core server URL and optionally set route_prefix="api" for direct Go access (bypassing Caddy):
client = MesahubClient(
api_key="your-admin-token",
api_url="http://localhost:4004",
route_prefix="api",
)
Metadata
Release files for mesahub 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mesahub-1.0.1.tar.gz | 9.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mesahub-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.3 kB
Release files / mesahub-1.0.1.tar.gz
| Download URL | mesahub-1.0.1.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
282240d5b352bf83153617870515a4ffcc1e125661e38c7b881922c298ec2171
|
|
BLAKE2b-256 checksum How to use checksums |
2617a8861b12a4a34541abcba5085b3de4606bf76c3372f50309b7cd61e988e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 10, 2026.
Transparency logRelease files / mesahub-1.0.1-py3-none-any.whl
| Download URL | mesahub-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d4f92a7f58ee08dd37bc309a371cd1a810dc07a1f0f95a1bbf84abefd169a98
|
|
BLAKE2b-256 checksum How to use checksums |
dc7bbec23e4a203bdf2160e93594a5758399e34346f8d65bdbf50394d39f7598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 10, 2026.
Transparency logSecurity for mesahub 1.0.1
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mesahub-1.0.1.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 May 10, 2026.
Transparency logA 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.