Registry / database / sql-autocomplete

sql-autocomplete

JSON →
library1.1.1jsnpmunverified

sql-autocomplete is a library for generating autocomplete suggestions for SQL statements across multiple dialects, including PostgreSQL, MySQL, SQL Server (T-SQL), and Oracle (PL/SQL). Current stable version is 1.1.1. It supports both browser and Node.js environments, ships TypeScript type definitions, and is maintained by modelDBA. Key differentiator: it provides dialect-specific keyword completion and context-aware table/column suggestions given optional schema input.

npm install sql-autocomplete
INSTALL
IMPORT
SIG · SQL-AUTOCOMPLETE
S
sql-autocomplete
databasejavascriptv1.1.1
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.

SQLAutocomplete
import { SQLAutocomplete } from 'sql-autocomplete'
const SQLAutocomplete = require('sql-autocomplete')
Correct import is named, not default. CommonJS require works but TypeScript/ESM preferred.
SQLDialect
import { SQLDialect } from 'sql-autocomplete'
import SQLDialect from 'sql-autocomplete'
SQLDialect is a named export, not a default export.
AutocompleteOption
import { AutocompleteOption } from 'sql-autocomplete'
AutocompleteOption is a type/class used in the return value; rarely imported directly but available.
SQLAutocompleteResult
import type { SQLAutocompleteResult } from 'sql-autocomplete'
Type-only import for TypeScript users; export exists but not documented.

Creates a SQLAutocomplete instance with PostgreSQL dialect, tables, and columns, then retrieves autocomplete suggestions for a partial SQL query.

import { SQLAutocomplete, SQLDialect } from 'sql-autocomplete'; const autocomplete = new SQLAutocomplete( SQLDialect.POSTGRESQL, ['employees', 'departments'], ['id', 'name', 'salary'] ); const sql = 'SELECT name FROM emp'; const suggestions = autocomplete.autocomplete(sql); console.log(suggestions); // Output: [ AutocompleteOption { value: 'employees', optionType: 'TABLE' } ]
Debug
Known issues
gotchaTable and column names must be provided as arrays; passing strings may cause unexpected behavior.
fix
Ensure second and third constructor arguments are arrays of strings.
affects: >=1.0.0
gotchaAutocomplete suggestions depend on the SQL dialect; using incorrect dialect may produce incomplete or wrong keywords.
fix
Select the appropriate SQLDialect enum for your target database.
affects: >=1.0.0
gotchaThe library does not parse SQL schema from a database; table and column names must be manually provided.
fix
Pass the known schema elements as constructor arguments or use an external schema retrieval tool.
affects: >=1.0.0
breakingIn v0.x, the export was a default class; v1 changed to named exports.
fix
Use import { SQLAutocomplete } from 'sql-autocomplete' instead of import SQLAutocomplete from 'sql-autocomplete'.
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
TypeError: Class constructor SQLAutocomplete cannot be invoked without 'new'
Using SQLAutocomplete as a function without 'new' keyword.
fix
Use 'new SQLAutocomplete(...)' to instantiate.
Cannot find module 'sql-autocomplete'
Module not installed or import path incorrect.
fix
Run 'npm install sql-autocomplete' and ensure import path is correct.
Property 'autocomplete' does not exist on type 'typeof SQLAutocomplete'
Calling autocomplete as a static method instead of on an instance.
fix
Create an instance first: const ac = new SQLAutocomplete(...); ac.autocomplete(...);
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
sql-autocomplete — npm install sql-autocomplete · libregistry