Documentation
¶
Overview ¶
Build and run some queries using the SQLC generator library. SQLC is very different from the other libraries, in that it expects you to provide it both your schema (or database connection) and a file containing a list of queries you want to convert into code. It then generates both the struct models and the golang functions to match each query. It works wonderfully for any non-dynamic queries, but unfortunately it does not really cover dynamic queries. For dynamic queries, it can actually work if you use CASE statement in the WHERE, but this isn't something you'd want to do when there are more than 2-3 optional conditions, as it will create a very ugly query that probably won't get optimized well. You could choose to make use of the generated models with other libraries for dynamic SQL generation. It also a bug around arrays/slices of enum types. SQLC works with both database/sql and PGX.