Start using new db base functions

This commit is contained in:
Tulir Asokan
2019-09-02 22:02:50 +03:00
parent 2c443a3b93
commit fbb1267609
11 changed files with 27 additions and 124 deletions
+1 -10
View File
@@ -16,9 +16,8 @@
from typing import Iterable
from sqlalchemy import Column, Integer, String
from sqlalchemy.engine.result import RowProxy
from mautrix.bridge.db import Base
from mautrix.util.db import Base
from ..types import TelegramID
@@ -34,14 +33,6 @@ class BotChat(Base):
with cls.db.begin() as conn:
conn.execute(cls.t.delete().where(cls.c.id == chat_id))
@classmethod
def scan(cls, row: RowProxy) -> 'BotChat':
return cls(id=row[0], type=row[1])
@classmethod
def all(cls) -> Iterable['BotChat']:
return cls._select_all()
def insert(self) -> None:
with self.db.begin() as conn:
conn.execute(self.t.insert().values(id=self.id, type=self.type))