import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
from random import randint
import sqlite3
import datetime
token = '***'
try:
    connection = sqlite3.connect("base.db", check_same_thread = False)
    cursor = connection.cursor()
    cursor.execute("""CREATE TABLE IF NOT EXISTS users (
        id INTEGER,
        cash INTEGER,
        date TEXT,
        prel TEXT
    )""")
    
except:
    print("Не удалось подключиться к базе данных!")
session = vk_api.VkApi(token = token)
vk = session.get_api()
def send(user_id, text):
    vk.messages.send(user_id = user_id, message = text, random_id = randint(-2147483648, +2147483648))
def sender(chat_id, text):
    vk.messages.send(chat_id = chat_id, message = text, random_id = randint(-2147483648, +2147483648))
def parc(text):
    if "ты получил" in text:
        try:
            index0 = text.find("[")
            index1 = text.find("|")
            id = int(text[index0 + 3:index1])        
            text = text[:index0].split(" ")
            for word in text:
                if "$" in word:
                    money = int(word[1:].translate(str.maketrans('', '', ".")))
            if cursor.execute(f"SELECT id FROM users WHERE id = {id}").fetchone() is None: 
                cursor.execute(f"INSERT INTO users VALUES ({id}, {money}, '{str(datetime.date.today())}')")
            else:
                cursor.execute(f"UPDATE users SET cash = cash + {money} WHERE id = {id}")
                cursor.execute(f"UPDATE users SET date = '{str(datetime.date.today())}' WHERE id = {id}")
            connection.commit()
        except Exception as ex:
            print(ex)
def count(user_id):
    if cursor.execute(f"SELECT id FROM users WHERE id = {user_id}").fetchone() is None:
        cursor.execute(f"INSERT INTO users VALUES ({user_id}, 0, '{str(datetime.date.today())}')")
        connection.commit()
        return 0
    else:
        time = cursor.execute(f"SELECT date FROM users WHERE id = {user_id}").fetchone()[0]
        connection.commit() 
        
        now = str(datetime.date.today())
        time = time.split('-')
        time = datetime.date(int(time[0]), int(time[1]), int(time[2]))
        now = datetime.date.today()
        itog = now - time
        itog = str(itog)
        try:
            itog = itog.split(" ")[0]
            itog = int(itog)
            
            if itog < 7: return 0
            elif itog >= 7 and itog < 14: return 30
            elif itog >= 14 and itog < 21: return 60
            elif itog >= 21 and itog < 28: return 90
            else: return 120
        except: return 0
print("QQ")
for event in VkLongPoll(session).listen():
    if event.type == VkEventType.MESSAGE_NEW and event.from_group:
        parc(event.text.lower())cursor.execute("""CREATE TABLE IF NOT EXISTS users (
        id INTEGER,
        cash INTEGER,
        date TEXT,
        prel TEXT
    )""")cursor.execute(f"INSERT INTO users VALUES ({id}, {money}, '{str(datetime.date.today())}')")prel TEXT И такое не в одном месте, вместо 4 преременных ожидаемых базой вы предоставили только 3.      cursor.execute(f"INSERT INTO users VALUES ({id}, {money}, '{str(datetime.date.today())}')")prel, но походу в данном случае она не нужна.NULL, т.е. ничего.cursor.execute(f"INSERT INTO users VALUES ({id}, {money}, '{str(datetime.date.today())}', NULL)")cursor.execute(f"INSERT INTO users (`id`, `cash`, `date`) VALUES ({id}, {money}, '{str(datetime.date.today())}')")NULL