pyxle-db 0.2.0
Changed (BREAKING)
Database.transaction()now yields a transaction whose methods are
coroutines:await tx.execute(...),await tx.fetchone(...), etc.
In 0.1 these calls were synchronous inside the async context manager.Database.close()andDatabase.sync_transaction()are SQLite-only
and raiseUnsupportedOperationErroron server backends. Use
await db.aclose()andasync with db.transaction()— both work on
every backend.- Mapping (named) parameters are SQLite-only; portable SQL uses
positional?parameters.
Added
-
PostgreSQL backend via
asyncpg(pip install 'pyxle-db[postgres]')
and MySQL backend viaasyncmy(pip install 'pyxle-db[mysql]').
The base install remains SQLite-only with zero extra dependencies. -
Database URLs:
Database(...)/connect(...)accept
sqlite:///...,postgresql://..., andmysql://...connection
strings alongside the 0.1 bare SQLite path.DatabaseConfigand
parse_database_urlare exported for programmatic use. -
Portable placeholders: qmark (
?) SQL is translated per backend
($1for PostgreSQL,%sfor MySQL) with a literal-aware rewriter;
??escapes a literal question mark for PostgreSQL JSON operators. -
Backend-neutral
Rowresult type (index + name access) andDialect
metadata, both exported frompyxle_db. -
New error types:
OperationalError(retryable connection/timeout
family),ConfigurationError, andUnsupportedOperationError.
Driver exceptions are translated on every backend — application code
never handlessqlite3/asyncpg/asyncmyexceptions. -
Datetimes come back timezone-aware UTC on every backend; naive values
stored in the database are assumed UTC and tagged. -
Plugin: new
urlsetting that takes precedence overpath, with
env:VAR_NAMEindirection so credentials stay out of the committed
pyxle.config.json(startup raisesConfigurationErrorwhen the
variable is unset). The plugin now also registersdb.url, a
password-redacted connection string for logging. -
Migrations: backend-specific override files
(0003-fulltext-index.postgresql.sqlnext to
0003-fulltext-index.sql) for migrations that need per-dialect DDL. -
DatabaseLike/TransactionLikeprotocols (pyxle_db.contract,
exported at top level): the structural contract third-party database
layers implement to back plugins like pyxle-auth.Databaseis the
reference implementation; both protocols areruntime_checkableand
the conformance is regression-tested.
Fixed
- Plugin shutdown awaits
Database.aclose(), releasing async pools
cleanly instead of relying on the SQLite-only synchronous close. - Aware datetimes now bind on every backend (found by the live-server
suites). PostgreSQL and MySQL pass parameters through
utc_naive_params(): an aware datetime is converted to UTC and bound
naive, matching the SQLite adapter and the read-side "naive equals
UTC" rule. Previously asyncpg rejected aware datetimes forTIMESTAMP
columns and asyncmy silently serialised the foreign wall clock. - The MySQL pool pins each session to UTC (
SET time_zone = '+00:00'),
soTIMESTAMPcolumns andNOW()are no longer shifted through the
server's system time zone on read. - The
mysqlextra now includescryptography: MySQL 8's default
caching_sha2_passwordauth fails at connect without it. - Dependency floor corrected to
pyxle-framework>=0.4.0— the
pyxle.pluginsAPI first shipped in 0.4.0, so older resolutions
could not import.
Install: pip install pyxle-db · extras: [postgres], [mysql]
Docs: https://pyxle.dev/docs/plugins/pyxle-db