JasonShin/sqlx-ts
JasonShin/sqlx-ts has 245 GitHub stars and 8 forks. Star changes are not measured yet. Last checked 2026-11-14 08:14 UTC. Last push 2026-10-18.
측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
node.js compile-time SQL validations & type generations
데이터README.md
Originalsqlx-ts
SQLx-ts is a CLI application featuring compile-time checked queries without a DSL and generates types against SQLs to keep your code type-safe
- Compile time checked queries - never ship a broken SQL query to production (and sqlx-ts is not an ORM)
- TypeScript type generations - generates type definitions based on the raw SQLs and you can use them with any MySQL, PostgreSQL, or SQLite driver
- Database Agnostic - support for PostgreSQL, MySQL, and SQLite
- TypeScript and JavaScript - supports for both TypeScript and JavaScript
Installation
Install sqlx-ts npm module (recommended)
If you are using npm
$ npm install sqlx-ts
If you are using yarn
$ yarn add sqlx-ts
You can also install sqlx-ts globally
$ npm install -g sqlx-ts
Installing sqlx-ts using npm also installed sqlx-ts binary of the same version as the npm module.
Verify the installation by running
$ npx sqlx-ts --version
And to use sqlx-ts in your code
In TypeScript based projects:
import { sql } from 'sqlx-ts'
// ...
const query = sql`SELECT * FROM some_table;`
// ...
In Babel based projects:
import { sql } from 'sqlx-ts'
const query = sql`SELECT * FROM some_table;`
// ... or
const { sql } = require('sqlx-ts')
const query = sql`SELECT * FROM some_table;`
Using Raw SQL Files
Create a SQL file with annotations:
-- users.sql
-- @name: getUserById
SELECT id, name, email FROM users WHERE id = $1;
-- @name: createUser
INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id;
Then, you can use the sqlx-ts CLI to generate TypeScript types and check the SQL queries
Installing binary separately
You may choose to install sqlx-ts separately instead of using npm i
Using install.sh
The binary name for sqlx-ts is sqlx-ts.
Archives of precompiled binaries of sqlx-ts are available for windows, macOS and Linux. Linux and Windows binaries are static executables. Users of platforms not explicitly mentioned below are advised to download one of these archives.
If you're a macOS user, then you can install sqlx-ts from via install.sh:
# macos & ARM CPU
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os darwin --cpu arm64
# macos & X64 CPU
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os darwin --cpu x64
If you're a Windows user, then you can install sqlx-ts from via install.sh:
# windows & x32
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os win32 --cpu x32
# windows & x64
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os win32 --cpu x32
If you're a Linux user, then you can install sqlx-ts from via install.sh:
# linux & x32
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os linux --cpu x32
# linux & x64
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os linux --cpu x64
# linux & arm
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --os linux --cpu arm64
To install a specific artifact, go to the release page to find the exact name of the artifact
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | sh -s -- --artifact sqlx-ts-v0.1.0-macos-arm.zip
Upgrading to a new version can be done by grabbing the next version of the sqlx-ts artifact and use --force command from install.sh
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | \
sh -s -- --artifact ssqlx-ts-v0.1.0-macos-arm.zip --force
For more advanced usage, please check --help command of install.sh
$ curl -LSfs https://jasonshin.github.io/sqlx-ts/install.sh | \
sh -s -- --help
Roadmap
Please check the public notion board for the current and future work items
sqlx-ts is not an ORM!
sqlx-ts supports compile-time checked queries and generated types against SQLs. It does not, however, do this by providing DSL (domain-specific language) for building queries. Instead, it provides a macro (almost) that take regular SQL as input and ensures that it is valid against the target database. The way it works is that sqlx-ts connects to your local or development database at compile-time and have database itself to verify the queries, also generate types based on information_schema. This can have many benefits that typical ORMs cannot provide
- Since sqlx-ts simply sends the queries back to the DB, almost any SQL syntax can be used in sqlx-ts (including things added by database extensions)
- You can easily optimize the queries as the SQLs are not built using a query-builder or an ORM interface
- The generated types work well with almost any database driver or even ORMs if they have good typescript support (that allows you to override input and output types)
but it comes with some implications
- The amount of information that sqlx-ts retrieves depend on the type of the database (e.g. MySQL vs PostgreSQL)
If you are looking for an ORM, you can checkout Sequelize or Prisma.
Using sqlx-ts in vanilla JavaScript
If you are trying to use sqlx-ts against vanilla JS, the TypeScript type-generation feature wouldn't be helpful. You can simply use SQL Check feature to keep your SQLs in JS code safe and compile-time checked.
Motivation
I would like to bring the powerful compile-time safety ideas to Node.js. sqlx is a great example of this, as it provides compile-time check of SQLs within your Rust code and Rust itself provides a great environment for tools like sqlx. sqlx-ts is greatly inspired by sqlx, but solves additional problems of generating TypeScript interfaces based on the SQL queries that are present in your code.
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,729 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,898 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,491 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,522 스타