NewConn vs NewPool #83
Answered
by
pashagolub
nikitacrit
asked this question in
Q&A
-
Hello! What is actually difference between NewConn vs NewPool? Any recommendation what should we use? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
pashagolub
Jul 26, 2022
Replies: 1 comment
-
Hello, depends on your application code. If you are using pgxpool package then you probably want func NewPool(options ...func(*pgxmock) error) (PgxPoolIface, error). If you are using pgx then you should use func NewConn(options ...func(*pgxmock) error) (PgxConnIface, error).
Regards |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nikitacrit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
depends on your application code. If you are using pgxpool package then you probably want func NewPool(options ...func(*pgxmock) error) (PgxPoolIface, error).
If you are using pgx then you should use func NewConn(options ...func(*pgxmock) error) (PgxConnIface, error).
*pgx.Conn
represents a single connection to the database and is not concurrency safe. Use sub-packagepgxpool
for a concurrency-safe connection pool.Regards