go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

Postgres connection pooling #249

Closed code19m closed 1 year ago

code19m commented 1 year ago

Thank you for amazing library!

Does this library support connection pooling? I tried get sql.DB from pgxpool.Pool object, but it seems this is not pooling anymore.

go-jet commented 1 year ago

Jet is independent of a way pooling is done. The only requirements is that database handle type (sql.DB, sql.Tx, ...) implements standard Queryable and Executable interface. pgxpool.Pool does not implements standard sql interfaces, so it is not possible to use jet and pgxpool.Pool. Although, it might be possible to wrap pgx types so that they support standard sql interfaces. Unless you need some pgxpool.Pool features I would recommend to use default sql connection pooling. For a driver you can use standard pgx driver - "github.com/jackc/pgx/v4/stdlib"