Add psycopg2 as an optional dependency and throw error at startup if db is not initialized

This commit is contained in:
Tulir Asokan
2019-08-07 00:00:59 +03:00
parent b4a1aacd12
commit 47cf63e0e6
4 changed files with 11 additions and 2 deletions
+3 -1
View File
@@ -13,6 +13,8 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from sqlalchemy.engine.base import Engine
from mautrix.bridge.db import UserProfile, RoomState
from .bot_chat import BotChat
@@ -23,7 +25,7 @@ from .telegram_file import TelegramFile
from .user import User, UserPortal, Contact
def init(db_engine) -> None:
def init(db_engine: Engine) -> None:
for table in (Portal, Message, User, Contact, UserPortal, Puppet, TelegramFile, UserProfile,
RoomState, BotChat):
table.db = db_engine