1
我想實現連接與SQLAlchemy的和pymysql池:Connection對象不可調用的 - 的SQLAlchemy/pymysql
import pymysql
import sqlalchemy.pool as pool
# Lifted from the pymysql docs: https://github.com/PyMySQL/PyMySQL/blob/master/example.py
cnx = pymysql.connect(host='localhost',user='xxxx',password='xxxx',db='mydatabase')
# Lifted straight from the SQLAlchemy docs http://docs.sqlalchemy.org/en/latest/core/pooling.html:
cnxPool = pool.QueuePool(cnx, max_overflow=10, pool_size=5)
conn = cnxPool.connect()
cursor = conn.cursor()
cursor.execute("select * from PUBLIC_URLS")
cursor.close()
我只是碰到下面的錯誤,在一個相當長的堆棧跟蹤的底部:
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-1.1.3-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 279, in <lambda> return lambda crec: creator() TypeError: 'Connection' object is not callable
有沒有人有什麼建議,有什麼不對?
感謝
嗯,就是這樣。謝謝 –