# knex/knex

A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.

Repository: https://github.com/knex/knex
Canonical: https://ross.abutalabs.com/products/knex
Homepage: https://knexjs.org/
Language: JavaScript
License: MIT
License Family: permissive
Topics: sql, knex, mysql, postgresql, sqlite3, javascript
Last push: 2026-06-26T15:02:12+00:00

## Health v2 (maintenance only)
Score: 92/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 89, release rhythm 90, longevity 100
- inputs: {"age_days": 4995, "days_push": 68, "days_rel": 68, "gap_med": 3.0, "n_releases_24m": 9}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 20342, forks 2217 (observed 2026-08-28T04:11:29.957215+00:00)

## What it is
Knex.js is a batteries-included SQL query builder for JavaScript supporting PostgreSQL, MySQL/MariaDB, CockroachDB, MSSQL, SQLite3, Oracle, and Amazon Redshift. It provides a fluent query and schema builder with transactions, connection pooling, streaming, migrations, and both promise and callback APIs.

## Use cases
- build sql queries programmatically in node.js
- write portable queries across multiple sql databases
- run database schema migrations
- manage transactions and connection pooling in node apps
- avoid writing raw sql strings by hand
- swap database backends without rewriting queries

## When to choose
- you want a flexible query builder rather than a full ORM
- you need to support multiple SQL dialects with one codebase
- you want migrations and schema management built in
- you use ORMs like Objection.js or MikroORM that build on Knex

## When to avoid
- you prefer a full-featured ORM with model relations out of the box
- you work outside the Node.js/JavaScript ecosystem
- you need a NoSQL or document database

## Facets
- artifact type: library
- maturity: stable
- function: database, database-driver, orm
- domain: databases, backend, web-development, developer-tools
- platform: -
- tags: sql-query-builder, query-builder, schema-migrations, multi-dialect, connection-pooling, transactions, nodejs, javascript

## Member repositories
- knex/knex (main) score 92

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:11:29.957215+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:59:02.278875+00:00, confidence not recorded.
  - readme: https://github.com/knex/knex (fetched 2026-08-28T04:11:29.957215+00:00, sha 3e4037c258b2)
  - homepage: https://knexjs.org/ (fetched 2026-08-29T07:57:58.404121+00:00, sha f77fba2b7873)
  - site_page: https://knexjs.org/faq (fetched 2026-08-29T07:57:58.413257+00:00, sha a2c3b5bea791)
  - site_page: https://knexjs.org/changelog.html (fetched 2026-08-29T07:57:58.415460+00:00, sha ff40bbdac081)
- Data as of 2026-08-30T08:39:29.467469+00:00.
