I am using python3.5 asyncio+aiomysql wrapped in docker to extract some strings from my db. I expect to get 'ваш-шиномонтаж.рф' but got ???-??????????.?? instead. (Mysql table use utf-8 encoding.)
Here is a code:
# encoding: utf-8
import asyncio
from aiomysql import create_pool
async def get_pool(loop):
return await create_pool(host='127.0.0.1', port=3306, user='dbu', password='pwd', db='db', loop=loop)
async def get_sites(pool):
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute(
"select canonic_domain from site where id=1132",
())
sites = await cur.fetchall()
for s in sites:
print(type(s[0]))
print(s[0])
return sites
def process():
loop = asyncio.get_event_loop()
pool = loop.run_until_complete(loop.create_task(get_pool(loop)))
sites = loop.run_until_complete(loop.create_task(get_sites(pool)))
if __name__ == "__main__":
process()
the output:
<class 'str'>
???-??????????.??
I expect:
<class 'str'>
'ваш-шиномонтаж.рф'
what could be the problem?