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

How to set isolation level using pools? #98

Closed
mmccarthy404 opened this issue Apr 14, 2020 · 4 comments · Fixed by #155
Closed

How to set isolation level using pools? #98

mmccarthy404 opened this issue Apr 14, 2020 · 4 comments · Fixed by #155
Labels
feature a feature request or enhancement

Comments

@mmccarthy404
Copy link

I'm looking to set the isolation level of all read transactions of a pool to "READ UNCOMMITTED" while talking to our production database. I've looked into odbc's odbcSetTransactionIsolationLevel, however, it seems as though that will only work with connections directly, not pools.

Please advice on the best way to get this accomplished!

@hadley hadley added the feature a feature request or enhancement label Jan 5, 2023
@hadley
Copy link
Member

hadley commented Jan 5, 2023

To support this, I think we'd need some way to register a function that's called every time a new DB connection is created.

@hadley
Copy link
Member

hadley commented Jan 15, 2023

Maybe onCreate() and onDestroy() arguments to the pool class?

pool <- dbPool(
  RSQLite::SQLite(),
  on_create = \(con) DBI::dbExecute(con, "SET SOMETHING")
)

@hadley
Copy link
Member

hadley commented Jan 27, 2023

Don't even need to change the class; just add a helper to dbPool. Implementation saved in git stash.

hadley added a commit that referenced this issue Jan 29, 2023
hadley added a commit that referenced this issue Jan 30, 2023
@schafnoir
Copy link

Just discovered the 'pool' package yesterday, and I appreciate how much it has improved the performance of my Shiny app as it interacts with a PostgreSQL database. One minor suggestion for the dbPool help page: It would be great to see the example code above with respect to how to properly use the onCreate argument. Thanks for all the great development work!

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

Successfully merging a pull request may close this issue.

3 participants