From eba6122aefc4366c05fe771221bcb28ba8180e46 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 16 May 2022 21:48:04 +0200 Subject: [PATCH] Add get_count --- advlabdb/dependent_funs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/advlabdb/dependent_funs.py b/advlabdb/dependent_funs.py index 430446f..a41a6dd 100644 --- a/advlabdb/dependent_funs.py +++ b/advlabdb/dependent_funs.py @@ -1,7 +1,7 @@ from flask import flash, url_for from flask_admin.menu import MenuLink from flask_security import current_user -from sqlalchemy import select +from sqlalchemy import func, select from . import app, db from .models import Semester @@ -83,3 +83,7 @@ def initActiveSemesterMenuLinks(space): def reportBadAttempt(message): print("BAD ATTEMPT:", message) # TODO: Log + + +def get_count(table): + return db.session.scalar(select(func.count()).select_from(table))