Closed keysona closed 7 years ago
If the connection is dead, the execute will raise a exception,instead of returning a None. Can you show detailed code?
You output the Exception, then what is the Exception? Through this can know the specific problem.
There is no exception output...
I use execute_transaction
to insert/update data, use execute
to query.
And I met a incredible scence: query return a last result, but I had change the data...no cache...finally, I restart the program, the query return correct result...
PyMysql autocommit acquiescence is Fasle, so query must also commit to query the latest data. helpers do not commit, i will fix this.
You can default to autocommit set to True, you can use the normal.
Thx !
I have set autocommit to true .
And I will spend 3 days to test!
@staticmethod
def get_database_pool():
if not TableBase._pool:
hostname, port, username, password, dbname = options.mysql_string.split(":")
get_logger().info("connect mysql(%s) by pool", options.mysql_string)
_pool = ConnectionPool(
max_connections=60,
idle_seconds=7200,
wait_connection_timeout=3,
host=hostname,
port=int(port),
user=username,
passwd=password,
db=dbname,
charset="utf8",
cursorclass=DictCursor,
autocommit=True
)
TableBase._pool = _pool
return TableBase._pool
Already fixed! You can reinstall lastest version. thanks.
I run a select statement, and result is None. But in database, it exist.
this is my log:
And first query return a user, second return a None.
I think may be this connection is dead ?