Answer the question
In order to leave comments, you need to log in
[Aiogram] When querying or flooding the database at the same time, it gives an error.?
I use the aiogram library and aiomysql. When I click on the button in the bot several times in a row or simultaneously on two accounts, it gives an error:
from data_base import mysql_db
async def command_info(message: types.Message):
user = await mysql_db.sql_query(str(message.from_user.id))
await bot.send_message(message.from_user.id, "Мой ID:" + str(user[0][2]) + "\n\nМонеты: " + str(user[0][4]),
parse_mode="Markdown")
loop = asyncio.get_event_loop()
async def sql_query(users):
try:
conn = await aiomysql.connect(host='None', user='None',
password='None', db='None',
loop=loop)
cur = await conn.cursor()
await cur.execute("SELECT * FROM users WHERE username='" + str(users) + "'")
print("You have successfully query")
r = await cur.fetchall()
print(r)
await cur.close()
conn.close()
except Error:
print("Wrong HOST or LOGIN or PASSWORD.")
raise (SystemExit)
if __name__ == '__main__':
loop.run_until_complete(sql_query())
Answer the question
In order to leave comments, you need to log in
In this situation, you can do with the usual animation from css (i.e. without setting the width from the script):
@кадры растянуть {
от { ширина: 0; }
до { ширина: 50%; }
}
.страница {
ширина: 0;
анимация: растянуть 1s;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question