api-database-mysql
MySQL Patterns (mysql2)
Quick Guide: Use mysql2/promise for all new code -- it provides async/await support over the mysql2 callback API. Always use
createPool()(nevercreateConnection()in production) withexecute()for parameterized queries (prepared statements, LRU-cached). Type query results withRowDataPacketgenerics for SELECTs andResultSetHeaderfor INSERT/UPDATE/DELETE. For transactions, acquire a dedicated connection withpool.getConnection(), wrap in try/finally to guaranteeconnection.release(). Never interpolate user input into SQL strings -- always use?placeholders. HandleER_DUP_ENTRYandER_LOCK_DEADLOCKexplicitly in catch blocks.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use execute() with ? placeholders for ALL queries containing user input -- NEVER interpolate values into SQL strings with template literals or string concatenation)
(You MUST use pool.getConnection() for transactions and release the connection in a finally block -- pool convenience methods (pool.execute()) use a different connection per call and cannot maintain transaction state)
(You MUST always import from mysql2/promise for async/await code -- the base mysql2 module returns callback-based objects that do not support await)
(You MUST handle the pool error event -- unhandled connection errors crash the Node.js process)
More from agents-inc/skills
web-animation-css-animations
CSS Animation patterns - transitions, keyframes, scroll-driven animations, @property, GPU-accelerated properties, accessibility with prefers-reduced-motion
24web-animation-view-transitions
View Transitions API patterns - same-document transitions, cross-document MPA transitions, shared element animations, pseudo-element styling, accessibility
21web-testing-playwright-e2e
Playwright E2E testing patterns - test structure, Page Object Model, locator strategies, assertions, network mocking, visual regression, parallel execution, fixtures, and configuration
21web-styling-cva
Class Variance Authority - type-safe component variant styling with cva(), compound variants, and VariantProps
20web-animation-framer-motion
Motion (formerly Framer Motion) animation patterns - motion components, variants, gestures, layout animations, scroll-linked animations, accessibility
20web-i18n-next-intl
Type-safe i18n for Next.js App Router
19