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

db_url.connect does not support pooling #581

Closed
foxx opened this issue Apr 24, 2015 · 3 comments
Closed

db_url.connect does not support pooling #581

foxx opened this issue Apr 24, 2015 · 3 comments

Comments

@foxx
Copy link
Contributor

foxx commented Apr 24, 2015

As seen here, there is no way to make connect() use a pooled connection. I've looked over the code and there doesn't appear to be any way to convert an existing DB object into a pooled one, at least short of using some horrible metaclass hacks or monkey patching.

Could someone clarify if this feature is on the roadmap, or whether a PR would be accepted if not?

@foxx
Copy link
Contributor Author

foxx commented Apr 24, 2015

In the mean time, for anyone who comes across this problem in the future, I was able to get a temporary monkeypatch working;

from playhouse import db_url
from playhouse.pool import PooledMySQLDatabase
db_url.schemes['mysql'] = PooledMySQLDatabase

The above will replace the MySQL backend with a pooled backend, whenever connect() is used. Replace classes accordingly for other databases, see here.

@coleifer
Copy link
Owner

You can use db_url.parse(url) to parse the data into a dictionary, then pass the dictionary values into a pooled database implementation. Because pooled databases require additional arguments (pool size, etc), they do not seem to me a good candidate for inclusion in the db_url module.

@foxx
Copy link
Contributor Author

foxx commented Apr 24, 2015

That works beautifully, thank you.

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

2 participants