import sqlite3
class Database:
def __int__(self, db_file):
self.connection = sqlite3.connect(db_file)
self.cursor = self.connection.cursor()
def user_exists(self, user_id):
with self.connection:
resalt = self.cursor.execute("SELECT * FROM 'users' WHER 'user_id' = ?", (user_id,)).fetchall()
return bool(len(resalt))
def add_user(self, user_id, referrer_id=None):
with self.connection:
if referrer_id!= None:
return self.cursor.execute("INSERT INTO 'users' ('user_id', 'referrer_id') VALUSE (?, ?)", (user_id, referrer_id,))
else:
return self.cursor.execute("INSERT INTO 'users' ('user_id') VALUSE (?)", (user_id,))
def count_of_users(self, user_id):
with self.connection:
return self.cursor.execute("SELECT COUNT('id') as count FROM 'users' WHERE 'referrer_id' = ?", (user_id,)).fetchone()[0]
это код database. пишет ошибку 'Database' object has no attribute 'connection'. Как это можно решить? (пишу реферальную систему)