sqlx VS sqlc

Compare sqlx vs sqlc and see what are their differences.

InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
Sevalla - Deploy and host your apps and databases, now with $50 credit!
Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
sevalla.com
featured
sqlx sqlc
79 185
17,120 15,842
0.6% 2.8%
3.3 8.9
about 1 year ago 3 days ago
Go Go
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

sqlx

Posts with mentions or reviews of sqlx. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2025-08-17.
  • Does OLAP Need an ORM
    4 projects | news.ycombinator.com | 17 Aug 2025
    > The sane middle ground is libraries that give you nicer ergonomics around SQL without hiding it (like Golangs sqlx https://github.com/jmoiron/sqlx). Engineers should be writing SQL, period.

    The blog suggests that an ORM for OLAP would do exactly that

  • 15 Go Packages Worth Your Time
    15 projects | dev.to | 26 Jun 2025
    sqlx builds on Go’s database/sql and adds useful features like named queries, struct mapping, and scanning slices.
  • Best Database Migration Tools for Golang
    6 projects | dev.to | 7 Jun 2025
    SQLx isn’t a migration tool per se, but it’s a powerful library for working with SQL in Go. You can build a custom migration system using SQLx to execute migration scripts, giving you ultimate flexibility. This approach is best for teams who want full control over their migration logic.
  • Structuring a Go Project with Clean Architecture — A Practical Example
    3 projects | dev.to | 25 May 2025
    4. Infrastructure Layer — internal/infra/ This layer implements database logic using go-jet and sqlx. It satisfies the interfaces defined in the domain layer.
  • 5 Golang Libraries You’ll Wish You Knew Sooner
    7 projects | dev.to | 18 May 2025
    ### When to Use Viper Use Viper for **applications with complex configurations**, like microservices or CLI tools. For simple scripts, environment variables alone might suffice. ## Comparing the Libraries Here’s a quick table to help you decide which library fits your needs. | Library | Use Case | Key Feature | Performance | Learning Curve | |---------|----------|-------------|-------------|----------------| | Gin | Web APIs | Routing | High | Low | | Testify | Testing | Assertions | N/A | Low | | Zap | Logging | Structured | High | Medium | | GORM | Databases| ORM | Medium | Medium | | Viper | Config | Flexibility | N/A | Low | ## Tips for Getting Started - **Start Small**: Try one library at a time in a side project. - **Read Docs**: Each library has excellent documentation (linked above). - **Join Communities**: Check GitHub issues or Go forums for tips. - **Experiment**: Use the example code as a base and tweak it. ## What’s Next? These libraries are just the tip of the iceberg. Once you’re comfortable, explore others like [Cobra](https://github.com/spf13/cobra) for CLI tools or [sqlx](https://github.com/jmoiron/sqlx) for lightweight database access. The Go ecosystem is vast, and combining these tools can help you build robust, scalable applications. Pick one library, try the example, and see how it fits your workflow. Happy coding!
  • Goravel: A Go framework inspired by Laravel
    9 projects | news.ycombinator.com | 9 Mar 2025
  • Building high-performance websites using htmx and Go
    2 projects | dev.to | 19 Feb 2025
    Go offers quick database interactions that result in fast performance. It provides both native database drivers and sqlx for simplified querying. As you have seen in this article, you have used native database driver, SQL just by importing a package straight from GitHub. Similarly, you can use sqlx to have reduced boilerplate and more built-in features like struct mapping.
  • Migrating Next.js App to GO + Templ & HTMX
    5 projects | dev.to | 5 May 2024
    sqlx for the database driver.
  • Python: Just Write SQL
    21 projects | news.ycombinator.com | 14 Aug 2023
    We've always used https://github.com/jmoiron/sqlx which is just the standard package + mapping to/from structs.
  • Golang equivalent of MyBatis/iBatis
    4 projects | /r/golang | 3 Jul 2023
    You can use this https://github.com/jmoiron/sqlx

sqlc

Posts with mentions or reviews of sqlc. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2025-08-26.
  • Nil Pointer Panic at 3 AM: Choosing the Right Go Database Tool to Save Your Sleep
    2 projects | dev.to | 26 Aug 2025
    SQLC is a modern marvel. It's not an ORM or a library; it's a code generator. You write raw SQL queries in .sql files, and sqlc generates fully type-safe, idiomatic Go code that you can call in your application.
  • I benchmarked nine Go SQLite drivers and here are the results
    6 projects | news.ycombinator.com | 18 Aug 2025
    I've been using the modernc driver for a few years in https://github.com/bbkane/enventory . It's worked perfectly with no drama. Combined with https://sqlc.dev/, I've been very happy writing (small) database applications in Go.
  • SQLx – The Rust SQL Toolkit
    16 projects | news.ycombinator.com | 25 Jul 2025
    Speaking of Go, if you want compile-time type checking like what SQLx offers, the Go ecosystem has an option that is arguably even better at it:

    https://sqlc.dev/

    It has the advantage that it implements the parsing and type checking logic in pure Go, allowing it to import your migrations and infer the schema for type checking. With SQLx you need to have your database engine running at compile time during the proc macro execution with the schema already available. This makes SQLx kind of a non-starter for me, though I understand why nobody wants to do what sqlc does (it involves a lot of duplication that essentially reimplements database features.)

  • Sqlc: Generate type-safe code from SQL
    1 project | news.ycombinator.com | 16 Apr 2025
  • sqlc: Type-Safe Querying in Go
    1 project | dev.to | 16 Mar 2025
  • Goravel: A Go framework inspired by Laravel
    9 projects | news.ycombinator.com | 9 Mar 2025
    What would you use if ORM is to be avoided?

    Perhaps something like https://github.com/sqlc-dev/sqlc ?

  • User authentication in go
    10 projects | dev.to | 30 Jan 2025
    Next, let's write sql queries for retrieving our users & their permissions. Here we will use sqlc for type-safe code generation from our sql queries, and pgx as its backend
  • Rails for Everything
    18 projects | news.ycombinator.com | 1 Jan 2025
  • Show HN: Generate type-safe code for SQL queries in any language
    2 projects | news.ycombinator.com | 27 Nov 2024
    sqlc (https://sqlc.dev/) is amazing, but I needed to use it in several unsupported languages. So instead of creating a plugin for each of those languages, I created a generic one, which is based on go templates.
  • Some Go web dev notes
    16 projects | news.ycombinator.com | 29 Sep 2024
    I really wanted to like sqlc, but it had some major limitations and minor annoyances last time I tried it a few months ago. You might want to go through its list of issues[1] before adopting it.

    Things like no support for dynamic queries[2], one-to-many relationships[3], embedded CTEs[4], composite types[5], etc.

    It might work fine if you only have simple needs, but if you ever want to do something slightly sophisticated, you'll have to fallback to the manual approach. It's partly understandable, though. It cannot realistically support every feature of every DBMS, and it's explicitly not an ORM. But I still decided to stick to the manual approach for everything, instead of wondering whether something is or isn't supported by sqlc.

    [1]: https://github.com/sqlc-dev/sqlc/issues/

    [2]: https://github.com/sqlc-dev/sqlc/issues/3414

    [3]: https://github.com/sqlc-dev/sqlc/issues/3394

    [4]: https://github.com/sqlc-dev/sqlc/issues/3128

    [5]: https://github.com/sqlc-dev/sqlc/issues/2760

What are some alternatives?

When comparing sqlx and sqlc you can also consider the following projects:

pgx - PostgreSQL driver and toolkit for Go

jet - Type safe SQL builder with code generation and automatic query result data mapping

go-sql-driver/mysql - Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

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

go-sqlite3 - sqlite3 driver for go using database/sql

ent - An entity framework for Go

InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
Sevalla - Deploy and host your apps and databases, now with $50 credit!
Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
sevalla.com
featured

Did you know that Go is
the 4th most popular programming language
based on number of references?