You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def add_guild(self, guild_id, guild):
async with self.bot.pool.acquire() as conn:
cur = await conn.cursor()
try:
await cur.execute(
"INSERT IGNORE INTO Guilds (guild_id, guild_name) VALUES (%s, %s);", (guild_id, str(guild),)
)
await cur.execute(
"INSERT IGNORE INTO G_Hangman (guild_id) VALUE (%s);", (guild_id,)
)
except (aiomysql.Error, aiomysql.Warning, mariadb.Warning, mariadb.Error) as e:
print(f"ERROR = {e}")
Even though there is an ignore statement, the log still catches the Duplicate Entry warning for Primary Key.
This is for a Discord game, and each time a game starts, this function runs, and outputs a line per member of the server which can result in thousands of lines on the console that are unnecessary and get in the way of the necessary output.
With the "except" statement, I have tried individual errors, combinations, IntegrityErrors, DatabaseError, and anything that could be related to the log being caught. It seems that the error handling is not able to catch the error. This COULD be a me problem, but it seems unlikely at this point based on what I've tried.
To Reproduce
I use PyCharm to test out the code before uploading it to a hosting software.
async def add_guild(self, guild_id, guild):
async with self.bot.pool.acquire() as conn:
cur = await conn.cursor()
try:
await cur.execute(
"INSERT IGNORE INTO Guilds (guild_id, guild_name) VALUES (%s, %s);", (guild_id, str(guild),)
)
await cur.execute(
"INSERT IGNORE INTO G_Hangman (guild_id) VALUE (%s);", (guild_id,)
)
except (aiomysql.Error, aiomysql.Warning, mariadb.Warning, mariadb.Error) as e:
print(f"ERROR = {e}")
Regardless of the error handling or "IGNORE" parameter in the query, the console prints a duplicate entry warning.
Warning: Duplicate entry 'xxxx-xxxx' for key 'PRIMARY'
await self._query(query)
(removed ID's to prevent doxxing)
Expected behavior
WIth the Ignore statement, I expected no output for the duplicate entries.
With the exception, I tried to catch it as a variable to see if it worked, however, it was not caught.
Logs/tracebacks
C:\Users\macke\Documents\Kambot\venv\lib\site-packages\aiomysql\cursors.py:239: Warning: Duplicate entry 'xxxxx-xxxxx' for key 'PRIMARY'
await self._query(query)
(removed ID's to prevent doxxing)
Python Version
Python 3.10.2
aiomysql Version
Name: aiomysqlVersion: 0.1.1 Summary: MySQL driver for asyncio. Home-page: https://github.com/aio-libs/aiomysqlAuthor: Nikolay Novik Author-email: nickolainovik@gmail.com License: MITLocation: c:\users\macke\documents\kambot\venv\lib\site-packagesRequires: PyMySQLRequired-by:
PyMySQL Version
Name: PyMySQLVersion: 1.0.2Summary: Pure Python MySQL DriverHome-page: https://github.com/PyMySQL/PyMySQL/Author: yutaka.matsubaraAuthor-email: yutaka.matsubara@gmail.comLicense: "MIT"Location: c:\users\macke\documents\kambot\venv\lib\site-packagesRequires:Required-by: aiomysql
SQLAlchemy Version
$ python -m pip show sqlalchemy
OS
Windows for the testing environment and Linux for the live environment.
Database type and version
10.6.8-MariaDB-1:10.6.8+maria~focal
Additional context
No response
Code of Conduct
I agree to follow the aio-libs Code of Conduct
The text was updated successfully, but these errors were encountered:
I meant to add this when I first posted, I apologize, not meaning to bump, but I came to look. If I'm just doing something wrong, I'm more than happy to be told so, I just don't know what I'm doing wrong if I am.
Describe the bug
Even though there is an ignore statement, the log still catches the Duplicate Entry warning for Primary Key.
This is for a Discord game, and each time a game starts, this function runs, and outputs a line per member of the server which can result in thousands of lines on the console that are unnecessary and get in the way of the necessary output.
With the "except" statement, I have tried individual errors, combinations, IntegrityErrors, DatabaseError, and anything that could be related to the log being caught. It seems that the error handling is not able to catch the error. This COULD be a me problem, but it seems unlikely at this point based on what I've tried.
To Reproduce
I use PyCharm to test out the code before uploading it to a hosting software.
async def add_guild(self, guild_id, guild):
async with self.bot.pool.acquire() as conn:
cur = await conn.cursor()
try:
await cur.execute(
"INSERT IGNORE INTO Guilds (guild_id, guild_name) VALUES (%s, %s);", (guild_id, str(guild),)
)
await cur.execute(
"INSERT IGNORE INTO G_Hangman (guild_id) VALUE (%s);", (guild_id,)
)
except (aiomysql.Error, aiomysql.Warning, mariadb.Warning, mariadb.Error) as e:
print(f"ERROR = {e}")
Regardless of the error handling or "IGNORE" parameter in the query, the console prints a duplicate entry warning.
Warning: Duplicate entry 'xxxx-xxxx' for key 'PRIMARY'
await self._query(query)
(removed ID's to prevent doxxing)
Expected behavior
WIth the Ignore statement, I expected no output for the duplicate entries.
With the exception, I tried to catch it as a variable to see if it worked, however, it was not caught.
Logs/tracebacks
Python Version
Python 3.10.2
aiomysql Version
PyMySQL Version
SQLAlchemy Version
$ python -m pip show sqlalchemy
OS
Windows for the testing environment and Linux for the live environment.
Database type and version
10.6.8-MariaDB-1:10.6.8+maria~focal
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: