From 27334b6e89cdec616ea6ac180ec1047a0bd4f54f Mon Sep 17 00:00:00 2001 From: Dmitrii Morozov Date: Wed, 27 Mar 2024 17:52:56 +0100 Subject: Draft persistence --- persistence.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 persistence.py (limited to 'persistence.py') diff --git a/persistence.py b/persistence.py new file mode 100644 index 0000000..eb1903f --- /dev/null +++ b/persistence.py @@ -0,0 +1,21 @@ +import sqlite3 + +class UserRepository: + + conn = None + + def __init__(self, db_path): + self.__initialize() + + def __initialize(self): + cur = self.__getConnection().cursor() + cur.execute("CREATE TABLE IF NOT EXISTS user(chat_id INT)") + + def __getConnection(self): + return sqlite3.connect('db.sqlite') + + def putUser(self, chat_id): + cur = self.__getConnection().cursor() + data_tuple = (chat_id) + print(type(chat_id)) + cur.execute("INSERT INTO user(chat_id) VALUES(?)", (chat_id, )) -- cgit v1.2.3