diff options
Diffstat (limited to 'persistence.py')
-rw-r--r-- | persistence.py | 21 |
1 files changed, 21 insertions, 0 deletions
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, )) |