diff --git a/src/gourmand/backends/db.py b/src/gourmand/backends/db.py index 7f538c97..f729cbd9 100644 --- a/src/gourmand/backends/db.py +++ b/src/gourmand/backends/db.py @@ -9,7 +9,7 @@ import sqlalchemy.orm from gi.repository import Gtk from sqlalchemy import (Boolean, Column, Float, ForeignKey, Integer, - LargeBinary, Numeric, String, Table, Text, event, func) + LargeBinary, Numeric, String, Table, Text, event, func, select) from sqlalchemy.sql import and_, case, or_ import gourmand.__version__ @@ -741,9 +741,9 @@ def fetch_len (self, table, **criteria): """Return the number of rows in table that match criteria """ if criteria: - return table.count(*make_simple_select_arg(criteria,table)).execute().fetchone()[0] + return select(*make_simple_select_arg(criteria,table)) else: - return table.count().execute().fetchone()[0] + return select([func.count()]).select_from(table) def fetch_join (self, table1, table2, col1, col2, column_names=None, sort_by=None, **criteria):