Create table "telegram_user_matrix_chats"
This commit is contained in:
parent
1d77e32174
commit
2ce7587d0a
1 changed files with 15 additions and 0 deletions
|
@ -6,6 +6,16 @@ import sys
|
|||
import aiogram as telegram
|
||||
import nio as matrix
|
||||
|
||||
TELEGRAM_USER_MATRIX_CHATS_SQL = '''
|
||||
CREATE TABLE IF NOT EXISTS telegram_user_matrix_chats (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
telegram_user_id INTEGER NOT NULL,
|
||||
matrix_chat_id INTEGER NOT NULL,
|
||||
FOREIGN KEY(telegram_user_id) REFERENCES telegram_users(id),
|
||||
FOREIGN KEY(matrix_chat_id) REFERENCES matrix_chats(id)
|
||||
)
|
||||
'''
|
||||
|
||||
def main():
|
||||
config = Config(
|
||||
db_path=os.environ['DB_PATH'],
|
||||
|
@ -84,6 +94,11 @@ class SqliteAdapter:
|
|||
self.app = app
|
||||
self.path = path
|
||||
self.conn = sqlite3.connect(path)
|
||||
self._create_tables()
|
||||
|
||||
def _create_tables(self):
|
||||
self.conn.execute(TELEGRAM_USER_MATRIX_CHATS_SQL)
|
||||
self.conn.commit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue