Как вставить словарь в базу данных sqlite3 telebot oython?
Начал писать telegram бота (библиотека telebot), который должен сохранять заказы в базу данных SQLite3. Происходит это так: пользователь вводит команду "/checkout" -> бот отправляет сообщение по типу "Отправьте ссылку/тип товара, цвет и т.д." -> пользователь вводит все необходимое -> и бот сохраняет в БД.
Вопрос: Не сохраняются (не вносятся) данные в базу данных, что мне делать? Подскажите PLEASE)
import telebot
from telebot import types
import configure
import sqlite3
bot = telebot.TeleBot(configure.config['token'])
checkout_info = {
'type': '',
'brand': '',
'size': '',
'colour': '',
'link': ''
}
@bot.message_handler(commands='checkout')
def checkout_link(message):
product_link = bot.send_message(message.chat.id, 'Укажите ссылку на ваш товар: ')
bot.register_next_step_handler(product_link, checkout_type)
def checkout_type(message):
checkout_info['link'] = message.text
product_type = bot.send_message(message.chat.id, 'Введите тип товара: ')
bot.register_next_step_handler(product_type, checkout_brand)
def checkout_brand(message):
checkout_info['type'] = message.text
product_brand = bot.send_message(message.chat.id, 'Введите бренд: ')
bot.register_next_step_handler(product_brand, checkout_size)
def checkout_size(message):
checkout_info['brand'] = message.text
product_size = bot.send_message(message.chat.id, 'Укажите размер товара: ')
bot.register_next_step_handler(product_size, checkout_colour)
def checkout_colour(message):
checkout_info['size'] = message.text
product_colour = bot.send_message(message.chat.id, 'Укажите цвет: ')
bot.register_next_step_handler(product_colour, checkout_all_info)
def checkout_all_info(message):
checkout_info['colour'] = message.text
bot.send_message(message.chat.id, f"ВАШ НОВЫЙ ЗАКАЗ: \n\nТип заказа: {checkout_info['type']} \nБренд: {checkout_info['brand']} \nРазмер: {checkout_info['size']} \nЦвет: {checkout_info['colour']} \nСсылка: {checkout_info['link']}")
bot.clear_step_handler(message)
#Подключаем базу данных
connect = sqlite3.connect('data.db')
cursor = connect.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS checkout_info(
type TEXT,
brand TEXT,
size TEXT,
colour TEXT,
link TEXT
)""")
connect.commit()
#Сохраняем данные в БД
cursor.execute("INSERT INTO checkout_info(type, brand, size, colour, link) VALUES(:type, :brand, :size, :colour, :link)", checkout_info)
connect.commit()
connect.close()