Skip to content

Conversation

kyleconroy
Copy link
Collaborator

@kyleconroy kyleconroy commented Jun 28, 2023

Running sqlc vet will now prepare your queries against a running database to check for any issues. The database is configured on a per-project basis. Right now, only PostgreSQL is supported, but I'll be adding MySQL support shortly.

Similar to the new lint rules, the database URL is a cel expression. It has access to a map of environment variables to pull in connection details from the environment.

version: "2"
sql:
  - schema: "postgresql/schema.sql"
    queries: "postgresql/query.sql"
    engine: "postgresql"
    database:
      url: "'postgresql://%s:%s@%s:%s/authors'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
    gen:
      go:
        package: "authors"
        out: "postgresql"

@kyleconroy kyleconroy marked this pull request as ready for review June 28, 2023 20:15
@kyleconroy kyleconroy merged commit 41c1520 into main Jun 28, 2023
@kyleconroy kyleconroy deleted the kyle/sqlc-vet-prepare branch June 28, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant