Invalid argument(s) 'pool_size' sent to create_engine(), using configuration
我们这里测试的是create_engine缺乏参数。
I create sqlalchemy
engine connecting to MySQL database. I want to specify charset
as create_engine
argument.
If I use create_engine
liKe that:
create_engine('mysql+mysqldb://pd:pd@localhost/pd?charset=utf8')
then all is fine. But, when I use it like that:
create_engine('mysql+mysqldb://pd:pd@localhost/pd', charset='utf8')
then I get the following error:
from sqlalchemy.pool import SingletonThreadPool
engine = create_engine('sqlite:///mydb.db', poolclass=SingletonThreadPool)
Passing in an explicit pool class also works on 0.6. Personally, I'd use exception handling here:
try:
engine = create_engine(URL, pool_size=10)
except TypeError:
# The pool_size argument won't work for the default SQLite setup in SQLAlchemy 0.7, try without
engine = create_engine(URL)