[Sqlalchemy-tickets] Issue #4039: pool_pre_ping not a valid kwarg for create_engine for MySQL (zzze
Brought to you by:
zzzeek
From: Heather L. <iss...@bi...> - 2017-07-31 20:05:56
|
New issue 4039: pool_pre_ping not a valid kwarg for create_engine for MySQL https://bitbucket.org/zzzeek/sqlalchemy/issues/4039/pool_pre_ping-not-a-valid-kwarg-for Heather Lent: I am on the most up-to-date SQLAlchemy (`1.1.12`), and trying to use the `pool_pre_ping=True` in the `create_engine()` function. Attempting to use pool_pre_ping results in an error, that pool_pre_ping is not a valid keyword argument. Here is a test that anyone can run to re-create the problem. Instructions for needed dependencies, my version of MySQL, and my driver are in the comments at the top of the code. You will need to replace `"mysql://...."` with the credentials for your own database. ``` #!python ''' Setup instructions for Python 3.4 or 3.5 (will probably work for any version of 3): pip install sqlalchemy=='1.1.12' pip install mysqlclient #database driver; necessary for MySQL & sqlalchemy for Python 3 I have MySQL version 5.6.33 on Ubuntu 14.04 ''' from sqlalchemy import create_engine #import create_engine engine = create_engine("mysql://username:password@localhost:port/dbname?charset=utf8mb4", pool_pre_ping=True) #attempt to create engine ''' FULL STACK TRACE ERROR: Traceback (most recent call last): File "test.py", line 10, in <module> engine = create_engine("mysql://username:password@localhost:port/dbname?charset=utf8mb4", pool_pre_ping=True) File "/home/hclent/anaconda3/lib/python3.5/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine return strategy.create(*args, **kwargs) File "/home/hclent/anaconda3/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 160, in create engineclass.__name__)) TypeError: Invalid argument(s) 'pool_pre_ping' sent to create_engine(), using configuration MySQLDialect_mysqldb/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components. ''' ``` I have attached this code in a `.py` file as well. Running it will show the error just as I have documented it (but make sure to follow the setup instructions!) Other comments: If I navigate to the directory where SQLALchemy files are `.../lib/python3.5/site-packages/sqlalchemy`, and try: `grep -r pool_pre_ping * | less ` There are no results, suggesting that pool_pre_ping is not actually valid for the stable release of sqlalchemy. I also checked the `__init__.py` in `sqlalchemy/engine`, where the `create_engine( )` function lives, and it does not mention pool_pre_ping anywhere. According to [this documentation](http://docs.sqlalchemy.org/en/latest/core/pooling.html#dealing-with-disconnects), `create_engine(..., pool_pre_ping=True)` should not fail. Since I am using MySQL and need a reliable connection pool for many users, disabling the pool as [suggested in Issue 3919](https://bitbucket.org/zzzeek/sqlalchemy/issues/3919) and [spelled out here](http://docs.sqlalchemy.org/en/latest/core/pooling.html#switching-pool-implementations) is not a good alternative. That being said, the release of [1.2.0b1](http://docs.sqlalchemy.org/en/latest/changelog/changelog_12.html#change-1.2.0b1) seems to have a bugfix that would allow me to do `create_engine.pool_pre_ping( ... )`. Does this mean I should be using an unstable version of SQLAlchemy? In summary, given the [documentation](http://docs.sqlalchemy.org/en/latest/core/pooling.html#pool-disconnects-pessimistic), the fact I'm using `SQLAlchemy 1.1.12`, I believe that there is a bug here. Please let me know if I am missing anything in my Issue (I believe I properly followed the guidelines) and if there's any way I can help contribute :) |