3 Commits
Author SHA1 Message Date
dsql febace7d5d chore: bump to 1.1.0 (logging-discipline audit)
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-08-10 23:00:50 -04:00
dsql 6eb3c2f841 fix: log-XOR-raise — demote the pre-raise log to DEBUG, revise the contract (D1)
every wrapped method did log.exception (ERROR + traceback) immediately before re-raising
the driver error — the same failure reported at two layers (the log AND the raised
exception). that is the log-and-raise violation: a method that re-raises must not also
error-log, because the caller — which alone knows whether the failure is fatal or routine
— is the one that logs. demote all wrapped-method logs to log.debug(..., exc_info=True):
the traceback stays available at DEBUG, and the raised exception is the single loud
terminal signal. docstring updated from "logs via getLogger and re-raises" to the
corrected raise-XOR-log contract. no behavior change beyond log level — the fail-loud
re-raise is unchanged.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-08-09 02:18:08 -04:00
dsql 2055ad978a release: 1.0.0
first stable release. pre-1.0.0 verification complete: all surviving MED regressions and
gaps resolved and independently re-fired, tree audited clean across the suite.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-09 18:53:15 -04:00
3 changed files with 24 additions and 21 deletions
+3 -3
View File
@@ -11,18 +11,18 @@ wire-compatible and share the driver, so this covers both.
`requirements.txt`:
```
mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v0.1.6
mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v1.0.0
```
Direct:
```bash
pip install "mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v0.1.6"
pip install "mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v1.0.0"
```
Pulls `aiomysql` (which pulls `PyMySQL`).
Drop the `@v0.1.6` suffix from the line above to install the latest unpinned.
Drop the `@v1.0.0` suffix from the line above to install the latest unpinned.
## The two-layer API
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mysql"
version = "1.0.0"
version = "1.1.0"
description = "async mysql/mariadb wrapper over aiomysql: two-layer API (friendly verbs + raw escape hatch), fail-loud, config-free"
requires-python = ">=3.10"
dependencies = [
+20 -17
View File
@@ -17,8 +17,11 @@ a literal `%` in layer-2 SQL text must be written `%%` only when params are pass
1 handles this for you.
errors are FAIL LOUD (unlike the mongo lib's swallow-and-default): every method catches
the driver error, logs via getLogger(__name__), and re-raises. a None/[] return is only
ever a real result, never a swallowed failure. for anything not wrapped, use `.pool`.
the driver error and re-raises it - the raised exception IS the signal, and the caller
(which alone knows whether a failure is fatal or routine) decides and logs. the wrapped
method itself logs only at DEBUG (with the traceback) so a failure isn't reported twice
(raise XOR log). a None/[] return is only ever a real result, never a swallowed failure.
for anything not wrapped, use `.pool`.
"""
import asyncio
@@ -135,7 +138,7 @@ class MysqlDB:
await cur.execute("SELECT 1")
await cur.fetchone()
except _DRIVER_ERRORS:
log.exception("mysql.connect() failed")
log.debug("mysql.connect() failed", exc_info=True)
if pool is not None:
pool.close()
await pool.wait_closed()
@@ -166,7 +169,7 @@ class MysqlDB:
self._pool.close()
await self._pool.wait_closed()
except _DRIVER_ERRORS:
log.exception("mysql.close()")
log.debug("mysql.close()", exc_info=True)
raise
finally:
self._pool = None
@@ -229,7 +232,7 @@ class MysqlDB:
try:
rowcount, _ = await self._run(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.execute(): %s", query)
log.debug("mysql.execute(): %s", query, exc_info=True)
raise
return rowcount
@@ -238,7 +241,7 @@ class MysqlDB:
try:
return await self._fetchall(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.fetch(): %s", query)
log.debug("mysql.fetch(): %s", query, exc_info=True)
raise
async def fetchone(self, query: str, params: Optional[Sequence] = None) -> Optional[dict]:
@@ -246,7 +249,7 @@ class MysqlDB:
try:
return await self._fetchone(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.fetchone(): %s", query)
log.debug("mysql.fetchone(): %s", query, exc_info=True)
raise
async def fetchval(self, query: str, params: Optional[Sequence] = None) -> Any:
@@ -254,7 +257,7 @@ class MysqlDB:
try:
row = await self._fetchone(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.fetchval(): %s", query)
log.debug("mysql.fetchval(): %s", query, exc_info=True)
raise
if not row:
return None
@@ -276,7 +279,7 @@ class MysqlDB:
try:
await self._run(f"CREATE DATABASE IF NOT EXISTS {_quote_ident_literal(name)}")
except _DRIVER_ERRORS:
log.exception("mysql.create_database(%s)", name)
log.debug("mysql.create_database(%s)", name, exc_info=True)
raise
async def create_table(self, name: str, schema: Dict[str, str]) -> None:
@@ -292,7 +295,7 @@ class MysqlDB:
try:
await self._run(f"CREATE TABLE IF NOT EXISTS {_quote_ident_literal(name)} ({cols})")
except _DRIVER_ERRORS:
log.exception("mysql.create_table(%s)", name)
log.debug("mysql.create_table(%s)", name, exc_info=True)
raise
async def drop(self, name: str, *, table: bool = True) -> None:
@@ -301,7 +304,7 @@ class MysqlDB:
try:
await self._run(f"DROP {kind} IF EXISTS {_quote_ident_literal(name)}")
except _DRIVER_ERRORS:
log.exception("mysql.drop(%s)", name)
log.debug("mysql.drop(%s)", name, exc_info=True)
raise
async def insert(self, table: str, values: Dict[str, Any]) -> int:
@@ -318,7 +321,7 @@ class MysqlDB:
try:
_, lastrowid = await self._run(query, list(values.values()))
except _DRIVER_ERRORS:
log.exception("mysql.insert(%s)", table)
log.debug("mysql.insert(%s)", table, exc_info=True)
raise
return lastrowid
@@ -333,7 +336,7 @@ class MysqlDB:
try:
return await self._fetchall(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.get(%s)", table)
log.debug("mysql.get(%s)", table, exc_info=True)
raise
async def get_one(self, table: str, conditions: Optional[Dict[str, Any]] = None) -> Optional[dict]:
@@ -343,7 +346,7 @@ class MysqlDB:
try:
return await self._fetchone(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.get_one(%s)", table)
log.debug("mysql.get_one(%s)", table, exc_info=True)
raise
async def delete(self, table: str, conditions: Optional[Dict[str, Any]] = None) -> int:
@@ -356,7 +359,7 @@ class MysqlDB:
try:
rowcount, _ = await self._run(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.delete(%s)", table)
log.debug("mysql.delete(%s)", table, exc_info=True)
raise
return rowcount
@@ -367,7 +370,7 @@ class MysqlDB:
try:
row = await self._fetchone(query, params)
except _DRIVER_ERRORS:
log.exception("mysql.exists(%s)", table)
log.debug("mysql.exists(%s)", table, exc_info=True)
raise
return bool(_first_value(row)) if row else False
@@ -390,7 +393,7 @@ class MysqlDB:
try:
rowcount, _ = await self._run(query, list(values.values()))
except _DRIVER_ERRORS:
log.exception("mysql.upsert(%s)", table)
log.debug("mysql.upsert(%s)", table, exc_info=True)
raise
return rowcount