PGXPool integration missing? #1797
Replies: 5 comments 3 replies
-
for ppl coming here later: when using pgx with compatibility mode (which is the case with importing from if you specifically wanna use pgxpool for pooling (whatever it does differently from standard pooling), it's not supported by ent at this point I'm assuing. |
Beta Was this translation helpful? Give feedback.
-
Coming in late here – is there support in ENT for postgres connection pooling? How? |
Beta Was this translation helpful? Give feedback.
-
Also coming late - would like to push this again :-) |
Beta Was this translation helpful? Give feedback.
-
@rajkong any updates or plans on the PR? |
Beta Was this translation helpful? Give feedback.
-
Late to the party, but hopefully this will provide an answer. pgxpool added sql.DB support. Hopefully this helps others who stumble across this question, since it took me a little bit to find the answer. poolConfig, err := pgxpool.ParseConfig("postgresql://user:pass@host/database")
if err != nil {
log.Fatal(err)
}
poolConfig.MaxConns = 20
poolConfig.MinConns = 0
poolConfig.MaxConnLifetime = time.Minute * 2
pool, err := pgxpool.NewWithConfig(context.TODO(), poolConfig)
if err != nil {
log.Fatal(err)
}
db := stdlib.OpenDBFromPool(pool)
drv := entsql.OpenDB(dialect.Postgres, db)
client := ent.NewClient(ent.Driver(drv)) |
Beta Was this translation helpful? Give feedback.
-
Hello!
What I am trying to do
I am trying to use pgx pools with ent.
Problem
pgxpool is a connection pool for pgx. pgx is entirely decoupled from its default pool implementation. This means that pgx can be used with a different pool or without any pool at all.
So, if I am not wrong, the only way of using a connection pool with pgx is with the pgxpool, something like this
will create only one connection.
Question
This is the only documentation that I found. I am missing something? is there any workaround or integration between ent and pgxpool?.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions