-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sqlc setup #455
base: main
Are you sure you want to change the base?
Add sqlc setup #455
Conversation
conn *pgxpool.Pool | ||
} | ||
|
||
var databaseURL = os.Getenv("POSTGRES_CONNECTION_STRING") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to load the env vars here via the utils.RequiredEnv
?
// Parse the connection pool configuration | ||
config, err := pgxpool.ParseConfig(databaseURL) | ||
if err != nil { | ||
log.Fatalf("Unable to parse database URL: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to do log.Fatal
here that does os.Exit
vs returning error so we can handle that (also by quitting probably).
// Create the connection pool | ||
pool, err := pgxpool.NewWithConfig(ctx, config) | ||
if err != nil { | ||
log.Fatalf("Unable to create connection pool: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the comment above about returning error.
@@ -0,0 +1,3 @@ | |||
-- name: Example :one | |||
SELECT * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the example here intentional?
if err != nil { | ||
log.Fatalf("Unable to create connection pool: %v", err) | ||
} | ||
defer pool.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the pool closed on defer, before we return the client?
It isn't ready yet, sorry |
Description
Minimal configuration for sqlc, the idea is to start minimal and progressively convert to sqlc.
This way we will have time to properly evaluate without huge investment on refactoring whole codebase. Also the style we want to use it will probably evolve.
Also started separating
shared
anddb
packages