knex
npmv3.3.0TypeScriptA batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3
Adopt with care
knex is usable, with caveats. Pulls in 22 transitive packages, about 3.2 MB installed (at least — some of the tree is still being crawled).
- ?Adoption: grade ?, Not reported by this registry.
No download data reported for this package yet.
- AMaintenance: grade A, Excellent.
Last published 75 days ago. 12 releases in the last 2 years.
- CWeight: grade C, Fair — worth a look.
Pulls in 22 transitive packages, about 3.2 MB installed (at least — some of the tree is still being crawled).
- ASupply chain: grade A, Excellent.
No install scripts, 5 maintainers, and a contained dependency surface.
- ALicense: grade A, Excellent.
MIT — permissive, with no copyleft found in the dependency tree.
Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.
Install cost
What you actually take on by adding knex to a project.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
Longest resolved dependency chain below this package.
Part of this dependency tree has not been crawled yet, so these figures are a lower bound rather than a final total.
Licenses in the dependency tree
Every license you inherit by installing knex, not just its own. Check this before a legal review, not after.
Compatibility
- Node.js
- node >=16
- Module format
- CommonJS only
- TypeScript
- Types included
- Install scripts
- None
Quick start
A usage example from the knex README.
const knex = require('knex')({
client: 'sqlite3',
connection: {
filename: './data.db',
},
});
try {
// Create a table
await knex.schema
.createTable('users', (table) => {
table.increments('id');
table.string('user_name');
})knex vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| knexthis page | 0 | 1 | MIT | 2 months ago |
| kysely | 15.6M | 1 | MIT | 1 day ago |
| drizzle-orm | 19M | 0 | Apache-2.0 | 1 day ago |
| postgres | 0 | 1 | Unlicense | 1 day ago |
| pg | 46.3M | 5 | MIT | 1 day ago |
| mongoose | 6.1M | 0 | MIT | 1 day ago |
Dependencies
Declared by knex v3.3.0. Runtime dependencies are installed with the package; dev dependencies are not.
Runtime (14)
Peer (1)
Dev (45)
Used by
Popular packages that depend on knex.
Relationship graph
Dependencies (left) and dependents (right) of knex.
Frequently installed together
TypeScript definitions for pg
PostgreSQL client - pure javascript & libpq with the same API
Type safe SQL query builder
fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS
libSQL driver for TypeScript and JavaScript
Fastest SQLite for React Native (with node.js support)
Public API for OpenTelemetry
Provides access to a database using SQLite (https://www.sqlite.org/). The database is persisted across restarts of your app.
A Fetch API-compatible PlanetScale database driver
The fastest and simplest library for SQLite in Node.js.
AWS SDK for JavaScript Rds Data Client for Node.js, Browser and React Native
TypeScript definitions for better-sqlite3
Release history
12 releases in the last two years, typically about 4 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 3.3.0latest | 2 months ago | 919 KB | MIT |
| 3.2.10 | 4 months ago | 895 KB | MIT |
| 3.2.9 | 5 months ago | 894 KB | MIT |
| 3.2.8 | 5 months ago | 893 KB | MIT |
| 3.2.7 | 5 months ago | 893 KB | MIT |
| 3.2.6 | 5 months ago | 931 KB | MIT |
| 3.2.5 | 5 months ago | 931 KB | MIT |
| 3.2.4 | 5 months ago | 930 KB | MIT |
| 3.2.3 | 5 months ago | 960 KB | MIT |
| 3.2.2 | 5 months ago | 960 KB | MIT |
| 3.2.1 | 5 months ago | 960 KB | MIT |
| 3.2.0 | 5 months ago | 960 KB | MIT |
| 3.1.0 | 2 years ago | 853 KB | MIT |
| 3.0.1 | 2 years ago | 847 KB | MIT |
| 3.0.0 | 2 years ago | 846 KB | MIT |
Overview
knex is an npm package that a batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3. It has 1 known dependents in the graph. The latest version is 3.3.0, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need a batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3 and value a focused solution.
When not to use it
Consider an alternative if you need to minimize your dependency tree, or if a more actively-maintained option better fits your npm stack.
Pros
- Ships TypeScript type definitions.
- Clear open-source license (MIT).
Cons
- Large dependency tree (60 direct dependencies) increases install size and audit surface.
Auto-generated from collected registry metadata. No external claims are inferred.
Frequently asked questions
Should I use knex?
knex is usable, with caveats. Pulls in 22 transitive packages, about 3.2 MB installed (at least — some of the tree is still being crawled).
How do I install knex?
Run `npm install knex` to add knex to your npm project.
How many dependencies does knex have?
knex declares 60 direct dependencies and pulls in 22 packages in total once its runtime tree is resolved totalling about 3.2 MB on disk.
What license is knex released under?
knex is distributed under the MIT license.
How popular is knex?
npm does not publish download counts. Within PackageGraph's crawl, 1 known packages depend on knex.
Is knex still maintained?
The most recent release of knex (v3.3.0) was published 2 months ago.
Does knex run install scripts?
No. knex does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.