from RXConfigBase import *
from RXSQLConfig import *
#from RXKeyboardConfig import *
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
#Начало, логиниться и регистрация
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.from_user.id, "Добро пожаловать!\n" f"♂️>> {message.chat.first_name}|{message.chat.last_name} <<♀️\n\n" "Входа в систему /log\n" "Регистрация /reg")
#регистрация
@bot.message_handler(content_types=['text'])
def reg(message):
if message.text == '/reg':
global user_id
global name
bot.send_message(message.from_user.id, 'Регистрация аккаунта.\nУкажите имя')
user_id = message.from_user.id
bot.register_next_step_handler(message, name)
elif message.text == '/log':
cursor.execute("SELECT name, surname, patronymic FROM users ORDER BY name, surname, patronymic")
name = cursor.fetchall()
surname = cursor.fetchall()
patronymic = cursor.fetchall()
bot.send_message(message.from_user.id, 'Профиль\n'
f'{name}\n'
f'{surname}\n'
f'{patronymic}'
)
#Собираем данные для регистрации и БД
def name(message): #получаем имя
if message.text:
bot.send_message(message.from_user.id, 'Укажите фамилию')
global name
name = message.text
bot.register_next_step_handler(message, surname)
def surname(message): #получаем фамилии
if message.text:
bot.send_message(message.from_user.id, 'Укажите отчество')
global surname
surname = message.text
bot.register_next_step_handler(message, patronymic)
def patronymic(message): #получаем отчества
if message.text:
bot.send_message(message.from_user.id, 'Регистрация окончено! Напиши /log')
global patronymic
patronymic = message.text
conn = sqlite3.connect("database/RXDataBase.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Profile (user_id, name, surname, patronymic) VALUES (?, ?, ?, ?)", (user_id, name, surname, patronymic))
conn.commit()
if __name__ == '__main__':
bot.polling(none_stop=True, interval=0)
Вся ошибка
line 27, in reg
cursor.execute("SELECT name, surname, patronymic FROM users ORDER BY name, surname, patronymic")
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 11400 and this is thread id 4040.