package postgresql import ( "context" "database/sql" "fmt" _ "github.com/lib/pq" ) type PGXClient interface { Prepare(query string) (*sql.Stmt, error) ExecContext(ctx context.Context, query string, arguments ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) } func NewPGXClient(psqlInfo string) (*sql.DB, error) { const op = "repository.postgresql.pq.NewConnection" db, err := sql.Open("pgx", psqlInfo) if err != nil { return nil, fmt.Errorf("%s: %w", op, err) } err = db.Ping() if err != nil { return nil, fmt.Errorf("%s: %w", op, err) } return db, nil }