|
@@ -12,6 +12,7 @@ from app.activities.RecipeEditor import RecipeEditor
|
|
|
from app.data.QueryManager import QueryManager, display_mapper
|
|
|
from app.palette import high_contrast
|
|
|
from app import parse_recipe
|
|
|
+import pandas as pd
|
|
|
import sys
|
|
|
|
|
|
try:
|
|
@@ -47,6 +48,7 @@ cur.execute("BEGIN;")
|
|
|
with open('units.sql') as f:
|
|
|
to_exec = ''
|
|
|
quote = False
|
|
|
+ conn.add_notice_handler(lambda x: print(f"[{x.severity}] {x.message_primary}"))
|
|
|
for line in filter(lambda x: x.strip() not in ('BEGIN;','ROLLBACK;'), f):
|
|
|
if line.startswith("""$$"""):
|
|
|
quote = True if not quote else False
|
|
@@ -57,10 +59,19 @@ with open('units.sql') as f:
|
|
|
continue
|
|
|
cur.execute(to_exec)
|
|
|
try:
|
|
|
- print(cur.fetchall())
|
|
|
+ data = pd.DataFrame(cur.fetchall(), columns=[
|
|
|
+ x.name for x in cur.description
|
|
|
+ ])
|
|
|
+ if not data.empty:
|
|
|
+ print()
|
|
|
+ print(cur._last_query)
|
|
|
+ print(data.to_string(index=False))
|
|
|
+
|
|
|
except psycopg.ProgrammingError:
|
|
|
pass
|
|
|
to_exec = ''
|
|
|
+
|
|
|
+ input("Press enter to continue")
|
|
|
|
|
|
activity_manager = ActivityManager()
|
|
|
query_manager = QueryManager(cur, display_mapper)
|