Registry / database / ts-mysql-analyzer

ts-mysql-analyzer

JSON →
library0.3.0jsnpmunverified

A TypeScript MySQL query analyzer that detects syntax errors, validates table/column names against a provided schema, performs type checking, and offers optimization suggestions like missing indexes. Currently at version 0.3.0, it uses the companion package ts-mysql-schema to extract schema information from a live MySQL database. Supports custom parser options (e.g., MySQL version, character sets) and multiple statements. Differentiates itself from generic SQL parsers by providing actionable feedback tied to an actual database schema, making it useful for development and CI environments to catch SQL issues early.

npm install ts-mysql-analyzer
INSTALL
IMPORT
SIG · TS-MYSQL-ANALYZER
T
ts-mysql-analyzer
databasejavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MySQLAnalyzer
import { MySQLAnalyzer } from 'ts-mysql-analyzer';
const { MySQLAnalyzer } = require('ts-mysql-analyzer');
Package is ESM-only; CommonJS require() will not work. Use dynamic import() if needed.

Initializes a MySQLAnalyzer with a schema fetched from a database and analyzes a simple SELECT query.

import { MySQLAnalyzer } from 'ts-mysql-analyzer'; import { MySQLSchema } from 'ts-mysql-schema'; const mySQLSchema = new MySQLSchema({ uri: 'mysql://root@127.0.0.1:3310/test' }); async function analyzeQuery() { const schema = await mySQLSchema.getSchema(); const analyzer = new MySQLAnalyzer({ schema }); const result = analyzer.analyze('SELECT * FROM users WHERE id = "123"'); console.log(result); } analyzeQuery();
Debug
Known issues
gotchaWithout providing a schema via ts-mysql-schema, the analyzer cannot validate table/column names or types.
fix
Ensure you create a MySQLSchema instance and pass its getSchema() result to MySQLAnalyzer.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'ts-mysql-schema'
ts-mysql-schema is a required peer dependency but is not installed.
fix
npm install ts-mysql-schema
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
ts-mysql-schemarequiredRequired to extract and provide the database schema for analysis
Agent activity
25 hits · last 30 days
node
20
Meta
2
Amazon
1
OpenAI (training)
1
Resources
ts-mysql-analyzer — npm install ts-mysql-analyzer · libregistry