summaryrefslogtreecommitdiff
path: root/persistence.py
blob: eb1903f1e51450fe44a84e65351bc0a1c3153ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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, ))