What problem does it solve?
Teams often end up mixing direct mysql2 usage with ad-hoc callback-based patterns, forgetting to manage connection lifecycles, and causing subtle bugs with transactions, streaming, and timezones. This Skill standardizes MySQL access by directing all database operations through a single async/iterable-friendly wrapper.
Core Features & Use Cases
- Promise-first convenience methods: Use consistent helpers for fetching one row, many rows, single values, or arrays of values.
- Safe streaming for large result sets: Process rows incrementally with async iteration, with automatic cleanup on
break/errors.
- Transaction-scoped database object: Run related operations on the same connection, with automatic commit/rollback and optional deadlock retries.
- Parameter binding helpers: Use positional and named parameters, plus an
IN helper that mutates binds and produces correct SQL fragments (including tuples and multi-row inserts).
- UTC timezone handling by default: Ensure consistent storage and retrieval of dates as UTC unless explicitly opting out for legacy schemas.
Use case examples
- Build a report job that streams millions of rows without exhausting memory.
- Implement a multi-step business update (select-for-update + update + insert) using a transaction-scoped db object to avoid deadlocks.
- Create a safe query layer that prevents accidental direct mysql2 usage and keeps all date handling consistent.
Quick Start
Tell the AI: Use mysql2-async to fetch a single row with getrow using a parameterized query and return the typed result.