georgysavva / scany

Library for scanning data from a database into Go structs and more
MIT License
1.31k stars 68 forks source link

Select with pgxpool Pool NewWithConfig #103

Closed trentmurray closed 1 year ago

trentmurray commented 1 year ago

I'm trying to figure out how to get scany to work with pgxPool where I build my connection using NewWithConfig rather than just the "New" function.

pool, err = pgxpool.NewWithConfig(context.Background(), config)
sqlscan.Select(r.Context(), pool, &wallet, `SELECT stripe_id FROM member_wallet WHERE member_uuid = ?`, "123")

it complains that

Cannot use 'pool' (type *pgxpool.Pool) as the type Querier Type does not implement 'Querier' as some methods are missing: QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

I've looked at everything in the Pool object, and nothing would conform to that requirement.. Any ideas?

georgysavva commented 1 year ago

Hi. You are using the wrong package. sqlscan is meant to work with the database/sql package. If you want to use scany with pgxpool.Pool, you need to use the pgxscan package instead.

Feel free to reopen the issue if you still have any questions.