0

I use aioodbc for connect to SQL Server for aiohttp. I was written 2 functions in python3:

async with aioodbc.create_pool(dsn=dsn, loop=loop, autocommit=True) as pool:
    async with pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(query)
            val = await cur.fetchall()

async def main(request):
    args = request.GET
    ses = request.cookies.get('sess')
    data = []
    try:
        data = await sqlQuery('dbo.sp_roles'+ " " + ses )
   except Exception as e:
        return web.Response(text = dumps({'message':str(e)}), status = 500)) 
   return web.Response(text = dumps(data))

and stored procedure in SQL Server. In the procedure, I use raiserror with cyrillic characters like this:

RAISERROR('пользователь не найден',16, 1)

and when I catch Exception as e in python function its looks like

������������ �� ������

Data with cyrillic characters in SELECT returns right. It's happened only when I raiserror. How can I get right error message in python?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

I found a solution. The reason was pyodbc old version. If you have the same error, you are must uninstall pyodbc pip uninstall pyodbc and install it (new version) again pip install pyodbc