由于某些原因我遇到了sqlalchemy处理连接池的问题,我不知道为什么。 这是我的日志:
2013-03-12 15:04:28 [19800] [DEBUG] Arbiter booted
2013-03-12 15:04:28 [19800] [INFO] Listening at: http://127.0.0.1:8000 (19800)
2013-03-12 15:04:28 [19800] [INFO] Using worker: gevent
2013-03-12 15:04:28 [19881] [INFO] Booting worker with pid: 19881
2013-03-12 15:04:29 [19881] [DEBUG] Created new connection <_mysql.connection open to 'XXX' at 8fb07a4>
2013-03-12 15:04:29 [19881] [INFO] SELECT DATABASE()
2013-03-12 15:04:29 [19881] [INFO] ()
2013-03-12 15:04:29 [19881] [INFO] Pool disposed. Pool size: 10 Connections in pool: 0 Current Overflow: -10 Current Checked out connections: 0
2013-03-12 15:04:29 [19881] [INFO] Pool recreating
这是最新的sqlalchemy 0.8.0和solaris上的mysql 5.5 Oracle Solaris 10 9/10 s10x_u9wos_14a X86
修改
以下是失败的更详细的转储:
Created new connection <_mysql.connection open to 'XXXX' at 8bcb704>
SELECT DATABASE()
()
Pool disposed. Pool size: 10 Connections in pool: 0 Current Overflow: -10 Current Checked out connections: 0
Pool recreating
Traceback (most recent call last):
File "/test/test_sqlalchemy.py", line 31, in <module>
result = db.session.execute("select * from app_config")
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 149, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 931, in execute
return self._connection_for_bind(bind, close_with_result=True).execute(
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 801, in _connection_for_bind
return self.transaction._connection_for_bind(engine)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 297, in _connection_for_bind
conn = bind.contextual_connect()
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1669, in contextual_connect
self.pool.connect(),
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 272, in connect
return _ConnectionFairy(self).checkout()
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 425, in __init__
rec = self._connection_record = pool._do_get()
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 777, in _do_get
con = self._create_connection()
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 225, in _create_connection
return _ConnectionRecord(self)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 322, in __init__
exec_once(self.connection, self)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/event.py", line 392, in exec_once
self(*args, **kw)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/event.py", line 409, in __call__
fn(*args, **kw)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 167, in first_connect
dialect.initialize(c)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2055, in initialize
default.DefaultDialect.initialize(self, connection)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 171, in initialize
self._get_default_schema_name(connection)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2022, in _get_default_schema_name
return connection.execute('SELECT DATABASE()').scalar()
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 664, in execute
params)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 808, in _execute_text
statement, parameters
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 878, in _execute_context
context)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 871, in _execute_context
context)
File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 320, in do_execute
cursor.execute(statement, parameters)
File "/test/bss/server/bss/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "/test/bss/server/bss/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
sqlalchemy.exc.InterfaceError: (InterfaceError) (0, '') 'SELECT DATABASE()' ()
任何想法是什么问题?
答案 0 :(得分:0)
我不确定是什么导致了这个问题但是使用了我的mysql而不是mysql-python,一切正常。