python MySQL pool is returning 'u' key in the array as like - [{u'data': u'{"no_comment":1,"total_reply":2}'}]
A required response should be like - [{"data": {"no_comment":1,"total_reply":2}}].
query - "select data from tbl_comment where id = 10"
reference code -
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