Python mysql池连接fetchall函数在数组中返回'u'关键字
python MySQL池正在返回数组中的'u'键,如下-[{u'data:u'{no_comment:1,total_reply:2}] 所需的响应应该是这样的-[{data:{no_comment:1,total_reply:2}] 查询-从id=10的tbl_注释中选择数据 参考代码-Python mysql池连接fetchall函数在数组中返回'u'关键字,python,mysql,multithreading,threadpool,connection-pooling,Python,Mysql,Multithreading,Threadpool,Connection Pooling,python MySQL池正在返回数组中的'u'键,如下-[{u'data:u'{no_comment:1,total_reply:2}] 所需的响应应该是这样的-[{data:{no_comment:1,total_reply:2}] 查询-从id=10的tbl_注释中选择数据 参考代码- def query(_db_config, _sql, _args): conn = get_pool_connection(_db_config) if not isinstance(conn
def query(_db_config, _sql, _args):
conn = get_pool_connection(_db_config)
if not isinstance(conn, PooledMySQLConnection):
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
else:
cursor = conn.cursor(dictionary=True)
result = ()
try:
cursor.execute(_sql, _args)
result = cursor.fetchall()
except:
pass
rootLogger.error("query exception sql is %s ,_args is %s,stacks is %s", _sql, _args, get_caller_info_total())
rootLogger.exception("message")
finally:
cursor.close()
conn.close()
return result
您可以这样尝试:
SELECT column1, CAST(CONVERT(column2 USING utf8) AS binary)
FROM my_table
WHERE my_condition;
您可以这样尝试:
SELECT column1, CAST(CONVERT(column2 USING utf8) AS binary)
FROM my_table
WHERE my_condition;
我使用encode函数获取数据。Unicode转换为ASCII用于解决方案。我使用encode函数获取数据。已将解决方案的Unicode转换为ASCII。已存在类似问题:已存在类似问题: