What is the difference between database/sql connection & pgx pool on golang?

1k views Asked by At

I'm trying to use ent on golang backed with postgresql DB.

Current legacy code uses pgxpool for connection pool. But ent does not support pgx pool, and only support standard connection pool of database/sql.

What is difference between two? Is it ok to use standard connection pool with PostgreSQL database? or should I use pgx pool for this?

1

There are 1 answers

0
Igor On

tl/dr;

  • database/sql - is an interface to access any database engines
  • pgx - is one of postgres driver (pq is a postgres driver too)
  • pgxpool - is a part of pgx which can work with connection pools of postgres

database/sql can be initialized to work with pgx driver for postgres. db, err := sql.Open("pgx", databaseDsn)

Is it ok to use standard connection pool with PostgreSQL database? or should I use pgx pool for this?

it depends of your needs