wsporto/typesql
wsporto/typesql has 336 GitHub stars and 14 forks. Star changes are not measured yet. Last checked 2026-11-14 04:23 UTC. Last push 2026-11-09.
What you can do
- Do not restrict the use of SQL You dont need to learn any new query language, you can use SQL with all its power and expressiveness.
- Infer parameters and columns types. SELECT DATEDIFF(:date1, :date2) as days_stayed will resolve the date1 and date2 parameters to the type Date and the function return type as number.
- Infer parameter and column nullability. The nullable database column email will generate a nullable field for the query SELECT email FROM mytable, but will generate a non-nullable field for the query SELECT email FROM mytable WHERE email is not null;
- Infer the query return type (single row vs multiple rows). If the id is a primary key or unique key, then function for the query SELECT * FROM Books where id = :id will return Book|null, instead of Book[]. The same is true for filters with LIMIT 1;
측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
TypeSQL - Generate Typescript API from raw SQL. Supports PostgresSQL, MySQL, Sqlite, LibSQL (Turso) and D1 (Cloudflare)
데이터README.md
OriginalTypeSQL
TypeSQL generates typesafe Typescript APIs from your SQL statements. Write your queries in raw SQL and TypeSQL generates the type-safe APIs to execute those queries.
Access your database directly without a heavy ORM, gain effortless type-safety, and make maintaining your SQL simple.
TypeSQL supports multiple SQL database backends:
PostgreSQL (Experimental)
- pg - PostgreSQL client for node.js.
MySQL
- mysql2 - the standard driver for mysql in NodeJS
SQLite
- better-sqlite3 - the fastest SQLite driver for NodeJS
- bun:sqlite - Bun's official high-performance SQLite driver
LibSQL
Cloudflare D1
- @cloudflare/d1 - Serverless SQLite-compatible database from Cloudflare.
Example
Having the following query in select-products.sql file.
SELECT
id,
product_name,
list_price
FROM products
WHERE discontinued = 0
AND list_price BETWEEN :minPrice AND :maxPrice
TypeSQL will generate the types and function in the file select-products.ts.
Then you can import the generate code and execute as following:
deno syntax:

Some features:
Do not restrict the use of SQL You dont need to learn any new query language, you can use SQL with all its power and expressiveness.
Infer parameters and columns types.
SELECT DATEDIFF(:date1, :date2) as days_stayedwill resolve thedate1anddate2parameters to the typeDateand the function return type asnumber.Infer parameter and column nullability. The nullable database column
emailwill generate a nullable field for the querySELECT email FROM mytable, but will generate a non-nullable field for the querySELECT email FROM mytable WHERE email is not null;Infer the query return type (single row vs multiple rows). If the
idis a primary key or unique key, then function for the querySELECT * FROM Books where id = :idwill returnBook|null, instead ofBook[]. The same is true for filters with LIMIT 1;Allow the use of dynamic ORDER BY with auto-completion and compile-time verification. See here.
Usage
- Install typesql globally:
npm install -g typesql-cli
- Add the
typesql.jsonconfiguration file in project root folder. You can generate an template with cli commandtypesql init.
{
"databaseUri": "mysql://root:password@localhost/mydb",
"sqlDir": "./sqls",
"client": "mysql2",
"authToken": "authtoken",
"includeCrudTables": []
}
Options:
| Option | Description | Example |
|---|---|---|
| client | Database client driver to use. |
|
| databaseUri | Connection string for the database. Supports environment variables (${VAR_NAME}). |
|
| sqlDir | Directory where SQL queries are stored. Will search recursively by appending the **/*.sql glob pattern. |
./src |
| authToken | Authentication token. Required only for the libsql client. Supports environment variables (${VAR_NAME}). |
|
| includeCrudTables | Generates select, insert, update, and delete queries for specified tables. |
['users', 'permissions', 'tags'] |
| generateIndexFiles | Whether to recursively generate index.ts barrel files in each output folder. Defaults to true if not specified. | true |
To load variables from a .env file, pass the --env-file flag:
typesql --env-file=.env compile
- Write your queries in the folder specified in the configuration file. You can also use the cli to scaffold the queries.
sqls\
select-products.sql
insert-product.sql
update-product.sql
- Then run
typesql compile --watchto start typesql in watch mode. After that you will have one Typescript file for each query file.
sqls\
select-products.sql
select-products.ts
insert-product.sql
insert-product.ts
update-product.sql
update-product.ts
- Now you can import and use the generated code.
const products = await selectProducts(...
const updateResult = await updateProduct(...
Examples
Project Status: Under Active Development
WARNING: This is a work-in-progress experimental project. It is under active development and its API might change.
Issues reports and feature requests are welcome.
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,711 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,894 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,491 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,522 스타