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

Support additional SQLAlchemy parameters. #540

Closed

Conversation

yangbaepark
Copy link

I found some SQLAlchemy parameters are helpful when we have unreliable network connectivity between applications and database.

  • creator helps to create custom DBAPI connections.
  • echo_pool will log all check-ins/outs of the pool.
  • pool_pre_ping tests connections for linveness upon each checkout.
  • pool_reset_on_return allows to override default behavior upon return.

By default, all those options are turned off (or following the default behavior in SQLAlchemy) for backward compatibility.

For more information about the parameters, please refer to the following official SQLAlchemy documentation:
http://docs.sqlalchemy.org/en/latest/core/engines.html#engine-creation-api

@gilbsgilbs
Copy link

I'm also willing to see those options in flask-sqlalchemy. They would need to be documented though.

@redixin
Copy link

redixin commented Dec 20, 2017

Some of these options are available only in sqlalchemy 1.2.0b3 (pre release)

@gilbsgilbs
Copy link

@redixin Yes, but it doesn't break support for previous versions anyways. It should just be documented.

@redixin
Copy link

redixin commented Dec 20, 2017

@gilbsgilbs
Copy link

@redixin I don't see your point, could you elaborate? This selector is compatible with sqlalchemy 1.2+.

@scythargon

This comment has been minimized.

@johanols
Copy link

johanols commented Mar 6, 2019

Looking closed and open PRs it seems that this is a highly requested feature. I for one would love to be able to set pool_pre_ping without having to sub-class SQLAlchemy. Reading through the comments, it assess these are the still open issues with this PR:

  • The added parameters needs to be documented.
  • The version pinning of the sqlalchemy package needs to be adjusted.

Is there a possibility to get this fixed and merged within the scope of this PR?

@redixin
Copy link

redixin commented Mar 7, 2019

@gilbsgilbs

@redixin I don't see your point, could you elaborate? This selector is compatible with sqlalchemy 1.2+.

Version 1.2 wasn't released at that moment. It is released now, but we still have 'SQLAlchemy>=0.8.0' in setup.py

Need to update setup.py as well.

@johanols
Copy link

johanols commented Mar 7, 2019

@gilbsgilbs Thank you for your quick respond!

So making this PR merge ready would be really simple. Unfortunately, the original author doesn't seem to be very active. Would it in that case make sense to abandon this PR in favor of a new one?

I could arrange that if desired.

@yangbaepark
Copy link
Author

yangbaepark commented Mar 7, 2019 via email

@davidism
Copy link
Member

davidism commented Mar 7, 2019

It doesn't look like you need to update anything right now, I'm not sure why users have commented saying you need to do so.

@gilbsgilbs
Copy link

Version 1.2 wasn't released at that moment. It is released now, but we still have 'SQLAlchemy>=0.8.0' in setup.py

Changing this selector would be a breaking change. There is no reason to prevent people from using this library with SQLAlchemy 1.1 and downwards, the library will keep working as before. We just need to document that the POOL_PRE_PING option will only work starting from SQLAlchemy 1.2+ (and document all the options that are added in this PR).

@davidism
Copy link
Member

davidism commented Mar 7, 2019

Just a heads up though, this probably won't get merged as I'd rather support a more general way to pass arguments to the pool, engine, and session rather than adding individual config keys. I'm leaving it open mainly because we'll need to organize all the related PRs and issues at some point.

Thanks for your work though, I don't mean to say it's not appreciated, just that it points to a larger goal we have.

@yangbaepark
Copy link
Author

Just a heads up though, this probably won't get merged as I'd rather support a more general way to pass arguments to the pool, engine, and session rather than adding individual config keys. I'm leaving it open mainly because we'll need to organize all the related PRs and issues at some point.

Thanks for your work though, I don't mean to say it's not appreciated, just that it points to a larger goal we have.

Sure, that makes sense. I agree it won't be sustainable to keep adding keys whenever SQLAlchemy introduces new parameters.

@rsyring
Copy link
Contributor

rsyring commented Mar 7, 2019

@davidism is this approach sufficient for you?

#166 (comment)

If so, a PR should be trivial.

@davidism
Copy link
Member

davidism commented Mar 7, 2019

Sure, that could work, I'd like it to pull from a class/instance init attribute of defaults as well so it's not only configurable via config (:thinking:).

@rsyring
Copy link
Contributor

rsyring commented Mar 7, 2019

@davidism I can do that.

@rsyring
Copy link
Contributor

rsyring commented Mar 8, 2019

Thank you for your contribution and sorry this took so long. We opted to go in a different direction but it will solve your use case. Please see: #684

@rsyring rsyring closed this Mar 8, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants