Closed IdeoG closed 6 years ago
Ok, i have fixed the issue recently. It was my bad, because i used one connection for all queries.
Sorry to comment on this, this late, but @IdeoG , what do you mean by used one connection for all queries? I'm having the same issue and I'd like to have some input on how you fixed this issue! Thanks :)
Hello, @cnicodeme
As you can see in my previous code i created self.conn
in start and used this singleton for whole queries i get. For example, for async insert_user
or get_user_by_id
.
So, you schould create connection from engine each time then you execute an operation. In code it's like as:
async def get_user_by_login(self, login):
async with self.engine.acquire() as conn:
result = await conn.execute(self.table.select().where(self.table.c.login == login))
user = await result.fetchone()
return user
async def get_user_by_id(self, id):
async with self.engine.acquire() as conn:
result = await conn.execute(self.table.select().where(self.table.c.id == id))
user = await result.fetchone()
return user
Best regards, Alex
Thank you your response @IdeoG . That's finally what I ended up doing while waiting for your answer so I think it's the right move :)
Hello, I'm using aiomysql library for a while in work project. I got asynchronious server with mysql database with follwing communication:
aiohttp <-> aiomysql + sa
.Here is my sample code.
This code works pretty good first 6 hours, but after some no-load operation, i get following error for every query to MySQL:
I tried to increase
pool_recycle
param, but it doesn't worked for me.How to solve the issue?
Best regards, Alex.