From 465a534317b2c50001045d6ff52a8f81b6e5ca87 Mon Sep 17 00:00:00 2001 From: Vassili Minaev Date: Mon, 17 Mar 2025 17:17:25 -0600 Subject: [PATCH] More fixes for linux --- apps/calendar/app.py | 8 +++++--- apps/reporter/queries.py | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/calendar/app.py b/apps/calendar/app.py index aaccae7..7a958fa 100644 --- a/apps/calendar/app.py +++ b/apps/calendar/app.py @@ -1,6 +1,7 @@ from aiohttp import web import aiohttp_security import datetime +import aiomysql import security @@ -16,9 +17,10 @@ def datetime_format(postdata): def init_app(app): async def db_query(query, params=()): - await app['cur'].execute(query, params) - q = app['cur'].mogrify(query, params) - r = await app['cur'].fetchall() + cursor = await app['con'].cursor(aiomysql.DictCursor) + await cursor.execute(query, params) + q = cursor.mogrify(query, params) + r = await cursor.fetchall() result = [{k: (str(v) if isinstance(v, datetime.date) or isinstance(v, datetime.timedelta) else v) for k, v in row.items()} for row in r] return (q, result) diff --git a/apps/reporter/queries.py b/apps/reporter/queries.py index 10cec4a..ec6315c 100644 --- a/apps/reporter/queries.py +++ b/apps/reporter/queries.py @@ -209,21 +209,21 @@ async def pivot_table(cursor, options): 'none' : ("", "", ""), 'month' : ("CONCAT(YEAR(O.OrderDate), '-', LPAD(MONTH(O.OrderDate), 2, '0')) AS month", "month", ""), 'year' : ("YEAR(O.OrderDate) AS year", "year", ""), - 'employee': ("CONCAT(E.firstname, ' ', E.lastname) AS employeename", + 'employee': ("CONCAT(E.FirstName, ' ', E.LastName) AS employeename", "employeename", - "LEFT JOIN employees AS E ON O.employeeid = E.employeeid"), - 'shipper' : ("SH.shippername", - "SH.shippername", - "LEFT JOIN shippers AS SH ON O.shipperid = SH.shipperid"), + "LEFT JOIN Employees AS E ON O.EmployeeID = E.EmployeeID"), + 'shipper' : ("SH.ShipperName", + "SH.ShipperName", + "LEFT JOIN Shippers AS SH ON O.ShipperID = SH.ShipperID"), 'customer': ("C.CustomerName", "C.CustomerName", - "LEFT JOIN customers AS C ON O.CustomerID = C.CustomerID"), - 'supplier': ("S.suppliername", - "S.suppliername", - "LEFT JOIN suppliers AS S ON P.SupplierID = S.SupplierID"), - 'category': ("CA.categoryname", - "CA.categoryname", - "LEFT JOIN categories AS CA ON P.CategoryID = CA.CategoryID"), + "LEFT JOIN Customers AS C ON O.CustomerID = C.CustomerID"), + 'supplier': ("S.SupplierName", + "S.SupplierName", + "LEFT JOIN Suppliers AS S ON P.SupplierID = S.SupplierID"), + 'category': ("CA.CategoryName", + "CA.CategoryName", + "LEFT JOIN Categories AS CA ON P.CategoryID = CA.CategoryID"), 'product' : ("P.ProductName", "P.ProductName", "") }