aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--quarg/main.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/quarg/main.py b/quarg/main.py
index ce72310..9532ba7 100644
--- a/quarg/main.py
+++ b/quarg/main.py
@@ -4,13 +4,13 @@ import os
import sys
from timeit import default_timer as timer
-from sqlalchemy import create_engine
+from sqlalchemy import create_engine, exc
from sqlalchemy.orm import sessionmaker
import quarg.actions as actions
import quarg.database.filters as filters
+import quarg.quassel.formatter as formatter
from quarg.database.tables import Backlog, Buffer, Network, QuasselUser, Sender
-from quarg.quassel.formatter import format_from
from quarg.utils import errx
# pylint: disable=line-too-long
@@ -136,11 +136,14 @@ def main():
if not predicates:
errx('Nothing to match.')
- query = prepare_query(session, predicates, args)
- rows, time = time_query(query)
+ try:
+ query = prepare_query(session, predicates, args)
+ rows, time = time_query(query)
- for row in rows:
- print(format_from(row))
+ for row in rows:
+ print(formatter.format_from(row))
+ except exc.SQLAlchemyError as err:
+ errx(err)
print(f'Query returned {len(rows)} lines in {time:.4f} seconds.', file=sys.stderr)