Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgxstore expects a *pgxpool.Pool instead of a *sql.DB #184

Open
tiagonbotelho opened this issue Nov 8, 2023 · 5 comments
Open

pgxstore expects a *pgxpool.Pool instead of a *sql.DB #184

tiagonbotelho opened this issue Nov 8, 2023 · 5 comments

Comments

@tiagonbotelho
Copy link

Hello,

I'm following along the Let's Go book (amazing book btw 🎉 ) and trying to adapt the code to use Postgres rather than MySQL.

However, one of the challenges I've encountered is that the session store that scs uses for Postgres (pgxstore) doesn't support the usage of the database/sql package (unlike the MySQL counterpart), since it expects a *pgxpool.Pool to be passed rather than a *sql.DB.

Since it seems to be a best practice to use the higher-level wrapper such as database/sql rather than a driver-specific library, I was wondering if there'd be any appetite in adding support for passing *sql.DB to pgxstore.New()

Thanks again for all the amazing contributions to the Go language 👏

@tiagonbotelho
Copy link
Author

To add to the issue description, one could definitely switch to using pq instead alongside the postgresstore. But pq does seem to point to pgx as the most up-to-date driver for Postgres.

@tiagonbotelho
Copy link
Author

I guess another alternative would be to just use the postgresstore but instead of using pq like recommended in the README just use pgx 👍

I'll give it a try and report back. Maybe this is something that can be clarified in the README as well 😊

@jum
Copy link
Contributor

jum commented Nov 10, 2023

I am using the pgx driver via the jackc/pgx/v5/stdlib interface to make it compatible to sqlx at. al., this works fine with postgresstore for scs. You can always get the pgx handle from the DB interface if you are so inclined to use the pgx interface.

@tiagonbotelho
Copy link
Author

👍 Same, I can confirm that I've been running the pgx driver using postgresstore for scs without any issues thus far. A small suggestion would be to clarify in the readme of that adapter that is supports pgx as well as pq.

I'd be happy to open a quick PR to make that clarification if we agree 😊

@alexedwards
Copy link
Owner

alexedwards commented Nov 11, 2023

@tiagonbotelho Thanks, that sounds good to me 👍 It would be great if you could update the README for postgresstore to include examples of both using it with pq and also jackc/pgx/v5/stdlib. If we're making that change, we should probably update the table in the main SCS README at https://github.com/alexedwards/scs/tree/master#configuring-the-session-store too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants