Utility library (v1.0.0) for detecting SQL operation types (SELECT, INSERT, UPDATE, DELETE, etc.), determining read-only status, and validating parameter binding. Supports positional ($1, ?) and named (@, :, $) parameter styles for PostgreSQL, MySQL, SQLite. Isomorphic (works in Node.js and browsers), with TypeScript support and 0 dependencies. Lightweight alternative to SQL parsers like sql-parser or node-sql-parser for simple query classification.
npm install check-sql-queryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Detects read-only SQL queries and validates parameter binding with positional and named placeholders.
Use only one style: either all $1 (PostgreSQL) or all ? (MySQL/SQLite)
For accurate operation detection on CTEs or subqueries, consider using a full SQL parser.
Pin to ^1.0.0 during initial adoption.
N/A
When using named params, ensure all placeholders are covered; unmatched keys are silently ignored.
If you need to detect any SELECT-like operation, check 'types' array directly.
Choose one style: e.g., 'SELECT * FROM users WHERE id = ? AND name = ?' or 'SELECT * FROM users WHERE id = $1 AND name = $2'.
Ensure the array length equals the placeholder count. For named parameters, use an object instead of an array.
Include all named parameters in the object, e.g., { id: 1 }.Use import { checkSqlQuery } from 'check-sql-query'.No dependency data recorded yet.