Registry / database / sqlite-statement-type

sqlite-statement-type

JSON →
library1.1.0jsnpmunverified

A lightweight, zero-dependency TypeScript library for determining the type of a SQLite SQL statement. Version 1.1.0 is the latest stable release, offering simple boolean functions for common SQL operations like SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE/DROP INDEX, CREATE/ALTER/DROP VIEW, PRAGMA, transactions, VACUUM, ANALYZE, ATTACH/DETACH, and REINDEX. The library uses basic string matching, so it is fast and suitable for parsing simple statements without complex grammar. It currently does not support recursive or compound statements. Ship with full TypeScript declarations. Released under MIT license with infrequent updates.

npm install sqlite-statement-type
INSTALL
IMPORT
SIG · SQLITE-STATEMENT-T
S
sqlite-statement-type
databasejavascriptv1.1.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.

isSelect
import { isSelect } from 'sqlite-statement-type'
const isSelect = require('sqlite-statement-type').isSelect
ESM-only; CommonJS require is not supported.
isInsert
import { isInsert } from 'sqlite-statement-type'
Named import; default import will not work.
isCreateTable
import { isCreateTable } from 'sqlite-statement-type'
Case-sensitive; function names match the exact export names.
all
import * as stmt from 'sqlite-statement-type'
Namespace import to access all functions.

Shows how to import and use two of the type-checking functions to determine SQLite statement types.

import { isSelect, isInsert } from 'sqlite-statement-type'; const selectSql = 'SELECT * FROM users'; const insertSql = "INSERT INTO users (name) VALUES ('Alice')"; console.log(isSelect(selectSql)); // true console.log(isInsert(insertSql)); // true console.log(isInsert(selectSql)); // false
Debug
Known issues
gotchaThe library uses simple string matching and does not parse SQL grammar. Queries with leading whitespace are handled, but case sensitivity may cause false negatives if keywords are not uppercase.
fix
Ensure SQL keywords are uppercase. For robust parsing, consider a full SQL parser.
affects: >=1.0.0
gotchaFunctions only check the first keyword of the statement. Compound statements like 'SELECT 1; SELECT 2' will only detect the first statement.
fix
Split compound statements before checking.
affects: >=1.0.0
gotchaAll functions are exported as named exports only. There is no default export, so import { isSelect } is required.
fix
Use named imports or namespace import.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: The requested module 'sqlite-statement-type' does not provide an export named 'default'
Attempting to import the library as a default export.
fix
Use named imports like: import { isSelect } from 'sqlite-statement-type'
isSelect is not a function
Using CommonJS require which returns an object; trying to call the object directly.
fix
Use ESM imports or destructure: const { isSelect } = require('sqlite-statement-type')
TypeError: isSelect is not a function
Misnamed import (e.g., import { isselect } with wrong case).
fix
Double-check the function name: it should be isSelect, isInsert, etc.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
sqlite-statement-type — npm install sqlite-statement-type · libregistry