</>PackageGraphPackageGraph

knex

npmv3.3.0TypeScript

A 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.

14
Direct dependencies

Runtime packages this one declares itself.

22
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

3.2 MB
Install size

Unpacked size of this package plus its entire runtime tree.

5
Tree depth

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

MIT

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');
    })
Example truncated — see the full README.

knex vs the alternatives

Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.

PackageWeekly downloadsDependentsLicenseLast release
knexthis page01MIT2 months ago
kysely15.6M1MIT1 day ago
drizzle-orm19M0Apache-2.01 day ago
postgres01Unlicense1 day ago
pg46.3M5MIT1 day ago
mongoose6.1M0MIT1 day ago

Dependencies

Declared by knex v3.3.0. Runtime dependencies are installed with the package; dev dependencies are not.

Peer (1)

pg-query-stream ^4.14.0

Dev (45)

@tsconfig/node12 ^1.0.11@tsconfig/recommended ^1.0.1@types/minimatch ^5.1.2@types/node ^20.4.0JSONStream ^1.3.5better-sqlite3 ^10.1.0chai ^4.3.6chai-as-promised ^7.1.1chai-subset-in-order ^3.1.0cli-testlab ^3.0.0cross-env ^7.0.3eslint ^8.54.0eslint-config-prettier ^8.6.0eslint-plugin-import ^2.29.0eslint-plugin-mocha-no-only ^1.1.1eslint-plugin-n ^17.23.1eslint-plugin-prettier ^4.2.1expect-type ^1.3.0faucet ^0.0.4husky ^8.0.1jake ^10.8.5lint-staged ^16.2.7mariadb ^3.5.2mocha ^10.0.0mock-fs ^5.1.4mysql ^2.18.1mysql2 ^3.2.0nyc ^15.1.0oracledb ^6.1.0pg ^8.20.0pg-query-stream ^4.14.0prettier 2.8.7rimraf ^5.0.5semver ^7.7.4sinon ^15.0.1sinon-chai ^3.7.0source-map-support ^0.5.21sqlite3 ^5.0.11tape ^5.6.0tedious ^18.2.1toxiproxy-node-client ^4.0.0ts-node ^10.9.1tsd ^0.28.1tstyche ^6.2.0typescript 5.4.5

Used by

Popular packages that depend on knex.

Relationship graph

Dependencies (left) and dependents (right) of knex.

Frequently installed together

Release history

12 releases in the last two years, typically about 4 days apart.

Recent versions of knex
VersionPublishedSizeLicense
3.3.0latest2 months ago919 KBMIT
3.2.104 months ago895 KBMIT
3.2.95 months ago894 KBMIT
3.2.85 months ago893 KBMIT
3.2.75 months ago893 KBMIT
3.2.65 months ago931 KBMIT
3.2.55 months ago931 KBMIT
3.2.45 months ago930 KBMIT
3.2.35 months ago960 KBMIT
3.2.25 months ago960 KBMIT
3.2.15 months ago960 KBMIT
3.2.05 months ago960 KBMIT
3.1.02 years ago853 KBMIT
3.0.12 years ago847 KBMIT
3.0.02 years ago846 KBMIT

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.

Maintainers

Keywords

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.