class DataBase:
def __init__(self,host_name: str, user_name: str, user_password: str) -> None:
# установка соединения с базой данных
self.conn = mysql.connector.connect(
host=host_name,
user=user_name,
passwd=user_password,
database="nekto"
)
# создание курсора для выполнения запросов
self.cursor = self.conn.cursor()
# создание таблицы "users"
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS users (
user_id INT PRIMARY KEY,
age INT,
description TEXT,
name TEXT,
image TEXT,
tags TEXT,
search_tags TEXT DEFAULT '',
last_activ FLOAT DEFAULT 0)
''')
self.conn.commit()
def get_user_dict(self, user_id: int) -> UserModel:
self.cursor.execute("SELECT * FROM users WHERE user_id=?", (user_id,))
result = self.cursor.fetchone()
self.conn.commit()
return dict(zip([column[0] for column in self.cursor.description], result))
File PATH/src/hendlers/menu.py", line 18, in get_main_menu
user_data = database.get_user_dict(message.peer_id)
│ │ │ └ 123
│ │ └ MessageMin(action=None, admin_author_id=None, attachments=[], conversation_message_id=_, date=_, deleted=None, fr...
│ └ <function DataBase.get_user_dict at 0x7ffbfd4ffa30>
└ <database.DataBase object at 0x7ffbfbe2a0b0>
File PATH/src/database.py", line 94, in get_user_dict
self.cursor.execute("SELECT * FROM users WHERE user_id=?", (user_id,))
│ │ │ └ 123
│ │ └ <function CMySQLCursor.execute at 0x7ffbfbe66320>
│ └ <mysql.connector.cursor_cext.CMySQLCursor object at 0x7ffbfbe2bac0>
└ <database.DataBase object at 0x7ffbfbe2a0b0>
File PATH/lib/python3.10/site-packages/mysql/connector/cursor_cext.py", line 325, in execute
raise ProgrammingError(
└ <class 'mysql.connector.errors.ProgrammingError'>
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement