A lightweight SQL utility library for Node.js that normalizes PostgreSQL and MySQL query building and execution. Current version 0.2.21. Provides a unified API with schema-aware insert/update validation, query builders (SELECT, INSERT, UPDATE), auto-parameter conversion (? -> $1 for Postgres), and result formatting. Differentiators: automatic column validation against database schema, logging support, and a simple builder pattern. Released under the MIT license by MacLaurin Group.
npm install mgsqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to Postgres, performs schema-validated insert, runs a parameterized query, and uses the builder pattern.
Use await on all .run() calls: await dbConn.run(builder);
Replace dbConn.insertIgnoreDuplicate('table', data) with builder pattern: dbConn.buildInsert().table('table').column(...).ignoreDuplicate()Restart the Node.js process after any DDL changes, or call a hypothetical reset (not provided).
Ensure field names only contain a-z, A-Z, 0-9 before calling, or use an alternative cleaning method.
Use .queryR() (raw) when your SQL already uses Postgres-style $N placeholders.
Run `npm install mgsql` and use `const mgsql = require('mgsql')` (CommonJS) or use dynamic import: `const mgsql = await import('mgsql')` in ESM.Ensure you call getPostgresWrap(pgClient, schemas) or getMySQLWrap(mysqlPool) and await the connection if needed.
Check the table schema and include all required columns in the data object, or alter the table to make the column nullable.
Verify the table name and schema exist. If using schemas, pass them as a comma-separated string to getPostgresWrap.
Use `await dbConn.run(builderObject)` and ensure the builder has .table() and appropriate clauses set.
No dependency data recorded yet.