move db init to web.py

This commit is contained in:
liamcottle
2024-05-04 20:22:10 +12:00
parent 0d6835fe04
commit 6960f076d3
2 changed files with 4 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ from datetime import datetime
from peewee import *
database = SqliteDatabase('storage/reticulum-webchat.db')
database = DatabaseProxy() # use a proxy object, as we will init real db client inside web.py
class BaseModel(Model):

3
web.py
View File

@@ -14,6 +14,8 @@ from aiohttp import web, WSMessage, WSMsgType, WSCloseCode
import asyncio
import base64
from peewee import SqliteDatabase
import database
@@ -29,6 +31,7 @@ class ReticulumWebChat:
self.load_config()
# init database
database.database.initialize(SqliteDatabase('storage/reticulum-webchat.db'))
self.db = database.database
self.db.connect()
self.db.create_tables([