mysql2-async

Official

Use async/await MySQL safely and consistently.

Authortxstate-etc
Version1.0.0
Installs0

System Documentation

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.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: mysql2-async
Download link: https://github.com/txstate-etc/mysql2-async/archive/main.zip#mysql2-async

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.