fix: connect() orphan (lockstep psql-3) + await pool.release() (mysql-1)

- connect() closes an existing pool on re-connect and tears down the built pool on SELECT-1
  validation failure (sibling of psql-3).
- _Transaction now awaits pool.release() in both __aexit__ and the __aenter__ failure path,
  matching psql and aiomysql's idiom (no un-awaited _wakeup task per transaction).
- README: insert-returns-lastrowid headline precision + upsert-rowcount convention note.
verified vs real MariaDB (re-connect, 5-tx release, full suite). bump v0.1.1 -> v0.1.2

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-01 00:28:27 -04:00
parent 2372b1ecd1
commit a46c4b13fc
3 changed files with 31 additions and 13 deletions
+11 -5
View File
@@ -11,24 +11,26 @@ 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.1
mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v0.1.2
```
Direct:
```bash
pip install "mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v0.1.1"
pip install "mysql @ git+ssh://git@git.rethinkstudios.io/rethink-public/mysql.git@v0.1.2"
```
Pulls `aiomysql` (which pulls `PyMySQL`).
Drop the `@v0.1.1` suffix from the line above to install the latest unpinned.
Drop the `@v0.1.2` suffix from the line above to install the latest unpinned.
## The two-layer API
**Layer 1 — friendly verbs** for simple single-table CRUD. These hide the dialect and are
**identical to the `psql` lib** — same method names, signatures, return shapes — so you
swap psql↔mysql with zero call-site changes.
**signature-identical to the `psql` lib** — same method names, arguments, and return
*types* — so you swap psql↔mysql with zero call-site changes. One value-level difference:
`insert()` returns the new row id (`lastrowid`) here vs. the inserted rowcount in psql
(both `int`); everything else returns the same shape.
**Layer 2 — raw escape hatch** for the complex ~20% (joins, aggregates, subqueries). You
write the SQL with `%s` placeholders + a params sequence; the wrapper still gives pooling,
@@ -111,6 +113,10 @@ Layer 1 is portable — you never see these. A Layer-2 raw-SQL author does:
`fetchone` is the unified Layer-2 name in both libs (psql maps it onto asyncpg's
`fetchrow` internally; here it's the native DBAPI verb).
`upsert()`'s returned rowcount follows MySQL's `ON DUPLICATE KEY UPDATE` convention (1 for
an insert, 2 for an update, 0 for a no-op) — a per-row count that differs from psql's; treat
it as "affected", not "rows matched".
## Error contract — fail loud
Unlike the `mongo` lib (which log-and-swallows), **this lib re-raises.** Every method