async def check_in_database_add(user):
try:
connection = pymysql.connect(
host=host,
user=user,
password=password,
database=db_name,
)
with connection.cursor() as cursor:
cursor.execute("SELECT id FROM main WHERE id = (%s)", (user[0].id))
if cursor.fetchone() is None:
with connection.cursor() as cursor:
cursor.execute("INSERT INTO main (id, score, nickname, lvl) VALUES (%s, %s, %s, %s)", (user[0].id,
0,
user[0].first_name,
1))
connection.commit()
except Exception as ex:
print('Connection to database is refused...')
print(ex)
user = await bot.api.users.get(message.from_id)
user имеет вид:
[UsersUserFull(элемент, элемент, элемент...)]
Вывод:
Connection to database is refused...
can't concat list to bytes
Смотрел некоторые ответы, говорят поменять %s на \"%s\" но не помогает.