sqlc: Generating go code from sql statements

This page summarizes the projects mentioned and recommended in the original post on /r/golang

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

    Since it has a decent amount of stars, I suspect that a lot of people know it already, but I came across a cool tool through a tutorial: https://github.com/kyleconroy/sqlc

  • SaaSHub

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

    SaaSHub logo
  • pg_query_go

    Go library to parse and normalize SQL queries using the PostgreSQL query parser

    If you are using Postgres then you are lucky! sqlc uses the official postgres parser (https://github.com/pganalyze/pg_query_go) and while I have never tried it, I guess it works really well.

  • parser

    A MySQL Compatible SQL Parser (by pingcap)

    For MySQL the situation is a bit different. sqlc uses the parser of TiDB (https://github.com/pingcap/parser), which is a parser that aims to be basically compatible with MySQL, but is quite young and is not a MySQL parser. The most basic queries work, but even simple joins or aggregations usually result in variables with unknown data types or wrong nullability. So you loose a lot of the benefits of sqlc. Manual type annotations for MySQL also do not work most of the time. They are simply ignored and forwarded to MySQL as invalid query if they do not occur on a place where sqlc is expecting them.

  • xo

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

    Thanks for sharing your thoughts! I see that it works best with Postgresql. The other commenter mentioned https://github.com/xo/xo for MySql which might work well.

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

  • ORMs are nice but they are the wrong abstraction

    7 projects | news.ycombinator.com | 1 Feb 2024
  • Sqlc: Compile SQL to type-safe code

    15 projects | news.ycombinator.com | 8 Sep 2024
  • DbGate - a fast cross-database client

    1 project | dev.to | 14 Aug 2024
  • PgManage: Modern, cross platform graphical database client

    9 projects | news.ycombinator.com | 21 Jul 2024
  • Trying out a new stack: my experience working with tRPC and Drizzle on my Next.JS project

    1 project | dev.to | 1 Jul 2024