A SQL query identifier that parses SQL statements to determine their type (e.g., SELECT, INSERT, CREATE_TABLE) by scanning and parsing tokens. Version 3.1.0 supports a wide range of SQL dialects including MySQL, PostgreSQL, BigQuery, and Oracle, with over 50 recognized statement types. Unlike full SQL parsers, it focuses on fast identification by checking only the initial keywords and structure, making it suitable for applications that need quick classification without full validation. It is actively maintained with regular releases and includes TypeScript type definitions. The package works in both Node.js and browser environments.
npm install sql-query-identifierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of identify() to classify SQL statements, including handling multiple queries and dialect-specific options.
Always execute the query against a database server before relying on the identifier for classification, especially for complex or dialect-specific statements.
Set the dialect option to 'mysql' when working with MySQL SHOW statements, or use 'generic' for basic support.
Update calls from identify(query, strictMode) to identify(query, { strict: strictMode }).Access queryResult.type directly instead of queryResult.type.type.
Ensure the query string is non-empty before calling identify() or wrap in a try-catch.
Use one of the supported dialects: 'mysql', 'postgresql', 'bigquery', 'oracle', or 'generic'.
Change from identify(query, true) to identify(query, { strict: true })No dependency data recorded yet.