Sqlc: Compile SQL to type-safe code

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • sqlc

    Generate type-safe code from SQL

    I missed this too. However, I've found you can work around it pretty easily with clauses like CASE WHEN @field != "" THEN column = @field ELSE true END.

    Example from the sqlc creator (https://github.com/sqlc-dev/sqlc/discussions/364#discussionc...):

      -- name: FilterFoo :many

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • services

    helpwave's microservices (by helpwave)

    Migrated from GORM to sqlc. We like the code generation approach with the simplistic abstractions.

    https://github.com/helpwave/services/tree/main/services/task...

  • xo

    Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server (by xo)

    XO doesn’t have them built-in, but it uses easily customizable templates.

    I added support for a bunch of postgres fancy stuff in a previous app, it wasn’t too difficult

    https://github.com/xo/xo

  • potygen

    Postgres SQL Parser and type generator

    There was a saying that before learning postgres in depth, the db is just a dumb store of data for devs, once you spend time to learn the tools it provides though, most applications just look like a very thin layer on top of the sql.

    There is so much more to rdbms (especially pg) than just joins - common table expressions, window functions, various views, let alone all the extensibility - extensions, custom types, even enums.

    All of that can enable writing performant, type safe and very compact applications.

    I am yet to see libs that embrace the elegance of it all - I’ve attempted this once - https://github.com/ivank/potygen but didn’t get much traction. I’m now just waiting for someone more determined to pick up those ideas - a client lib that exposes the type safety and intellisence at compile time and allows you to easily compose those sql queries.

    I think this project has some ways to go to reach that though, but thankfully it is a step in the right direction.

  • squiller

    Generate boilerplate from annotated SQL queries

    To add one to the mix: https://docs.ruuda.nl/squiller/

  • jOOQ

    jOOQ is the best way to write SQL in Java

  • feldera

    The Feldera Incremental Computation Engine

    This is somewhat common when high performance is needed it seems: e.g., https://github.com/feldera/feldera comes to mind which uses the same approach to compile SQL to type-safe incremental query plans in rust.

  • cornucopia

    Generate type-checked Rust from your PostgreSQL.

  • kysely

    A type-safe typescript SQL query builder

    Surprised nobody has mentioned “Kysely” (https://kysely.dev).

    It is a query builder (not an ORM), that (ab)-uses the Typescript type system to give you full type safety, intellisense, autocomplete etc.

    Crucially it doesn’t require any build/compile step for your queries which is fantastic.

  • slonik

    A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.

    Didn’t use myself, but AFAIK slonik library is doing what you’ve described: https://github.com/gajus/slonik

  • SQLDelight

    SQLDelight - Generates typesafe Kotlin APIs from SQL

  • crawshaw

    Low-level Go interface to SQLite 3 using cgo

    Not everything. Most SQL databases differ enough that it's worth using bindings specific to them. For example https://github.com/go-llsqlite/crawshaw?tab=readme-ov-file for SQLite.

    I can't get behind something like SQL because if it doesn't support your language or SQL dialect or the feature you need you're worse off than not using it.

  • sqlx

    🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite. (by launchbadge)

    This looks like a less ergonomic version of Rust's SQLx (https://github.com/launchbadge/sqlx) but a more robust version of TypeScript's sqlx-ts (https://jasonshin.github.io/sqlx-ts/). Sqlc seems to copy the latter's unfortunate lack of inline SQL statements. Still, seems promising.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • 👻Top 8 Free, Open Source SQL Clients🔥

    8 projects | dev.to | 4 Sep 2023
  • Open-sourcing SQX, a way to build flexible database models in Go

    5 projects | news.ycombinator.com | 2 Sep 2023
  • Best sqlc alternative for dynamic queries?

    8 projects | /r/golang | 15 May 2023
  • No/Low Code SQLite Front End GUI/Forms

    7 projects | /r/sqlite | 1 Feb 2023
  • I Migrated from a Postgres Cluster to Distributed SQLite with LiteFS

    4 projects | news.ycombinator.com | 5 Jan 2023

Did you konow that Rust is
the 5th most popular programming language
based on number of metions?