Registry / database / sql-g
library1.0.0jsnpmunverified

A lightweight JavaScript/TypeScript library that generates SQL query strings from a chainable API. Version 1.0.0 provides methods to build SELECT, INSERT, UPDATE, DELETE queries with support for WHERE, JOIN, GROUP BY, ORDER BY, and LIMIT clauses. It is designed for Node.js environments and ships TypeScript declarations. The library is minimal with no dependencies, offering a simple alternative to full ORMs like knex.js for cases where raw SQL strings are needed. Release cadence is unknown, but the API covers basic CRUD operations with chaining.

npm install sql-g
INSTALL
IMPORT
SIG · SQL-G
S
sql-g
databasejavascriptv1.0.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.

default export (sqlG)
import sqlG from 'sql-g'
import { sqlG } from 'sql-g'
The module exports a default function/object via ESM; named import will be undefined. Use default import.
CommonJS require
const sqlG = require('sql-g')
const { sqlG } = require('sql-g')
In CommonJS, the entire module is the default export. Destructuring will result in undefined.
TypeScript types
import sqlG from 'sql-g' // types are included
Types are shipped with the package; no separate @types package needed.

Shows how to import sql-g and build a SELECT query with conditions, ordering, and limit using method chaining.

import sqlG from 'sql-g'; // ESM // const sqlG = require('sql-g'); // CommonJS const query = sqlG .createSelectQuery('users') .select(['id', 'name', 'email']) .where('age', 18, '>') .orderBy('name') .limit(0, 10) .getQuery(); console.log(query); // Output: 'SELECT id, name, email FROM users WHERE age > '18' ORDER BY name LIMIT 0, 10'
Debug
Known issues
gotchaThe package name is 'sql-g', not 'sqlG' or 'SQLgenerator'. Ensure correct npm package name.
fix
npm install sql-g
affects: >=1.0.0
gotchaThe module is ESM-only when using import; requires Node.js with ESM support or a bundler. CommonJS still works with require().
fix
Use 'type': 'module' in package.json or use require() for CommonJS.
affects: >=1.0.0
gotchaAll query-building methods return the same instance for chaining; getQuery() must be called at the end to obtain the SQL string.
fix
Ensure you call .getQuery() after building the query.
affects: >=1.0.0
gotchaThe select() method expects an array of arrays: [['field1'], ['field2']]. Passing a flat array may produce unexpected results.
fix
Use select([['field1'], ['field2']]) or select(['field1', 'field2']) (depends on version; check docs).
affects: >=1.0.0
deprecatedThe method createInsertQuery appears twice in the docs; likely a duplicate. The correct signatures may not match.
fix
Refer to the actual implementation or test the API before relying on it.
affects: ~1.0.0
Errors
Common errors & fixes
TypeError: sqlG.createSelectQuery is not a function
Incorrect import: using named import instead of default import (e.g., import { sqlG } from 'sql-g').
fix
Use default import: import sqlG from 'sql-g'
Cannot find module 'sql-g'
Package not installed or wrong package name.
fix
Run npm install sql-g
SyntaxError: Unexpected token '.'
Using ESM import in a CommonJS file without setting 'type': 'module'.
fix
Use require('sql-g') or add 'type': 'module' to package.json.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
packagesql-g
sql-g — npm install sql-g · libregistry