Registry / database / davesql

davesql

JSON →
library0.6.3jsnpmunverified

A lightweight SQL interface for Node.js projects, providing a simplified API for database queries. Version 0.6.3 is current, with infrequent updates based on author's needs. It wraps callback-based SQLite operations into promises. Differentiators: minimalistic design, zero dependencies, and direct SQL execution without ORM abstractions.

npm install davesql
INSTALL
IMPORT
SIG · DAVESQL
D
davesql
databasejavascriptv0.6.3
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
import davesql from 'davesql'
const { davesql } = require('davesql')
Default export only; use default import for ESM.
query
import davesql from 'davesql'; davesql.query(...)
import { query } from 'davesql'
query is a method on the default export, not a named export.
execute
import davesql from 'davesql'; davesql.execute(...)
const { execute } = require('davesql')
Likewise, execute is a method on the default export.

Shows basic usage: create in-memory database, create table, insert, select, and close.

import davesql from 'davesql'; const db = davesql.create({ file: ':memory:' }); await db.query('CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)'); await db.query("INSERT INTO test (name) VALUES ('Hello')"); const rows = await db.query('SELECT * FROM test'); console.log(rows); // [{ id: 1, name: 'Hello' }] await db.close();
Debug
Known issues
gotchaUsing synchronous methods (e.g., querySync) can block the event loop.
fix
Use async methods (query, execute) instead.
affects: >=0.0.0
gotchaOnly supports SQLite; attempts to use with other databases will fail.
fix
Use a database-specific driver for MySQL, PostgreSQL, etc.
affects: >=0.0.0
gotchaDefault export may be mistaken for a constructor; it is already an object.
fix
Use davesql.create() or davesql directly, not new davesql().
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: davesql is not a function
Called default export as a function (e.g., davesql()) instead of accessing methods.
fix
Use davesql.create({ file: 'db.sqlite' }) or davesql.query(...).
Error: Cannot find module 'davesql'
Package not installed or import path incorrect.
fix
Run npm install davesql and use import davesql from 'davesql'.
TypeError: Cannot read properties of undefined (reading 'query')
Calling query on uninitialized object (likely forgot to call create).
fix
Initialize with const db = davesql.create({ file: 'db.sqlite' }); then db.query(...).
Upgrade
Version history
0.6.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
davesql — npm install davesql · libregistry