import time import config from connectors import mysql logger = config.logger def main() -> None: connection = mysql.get_mysql_connection() with connection.cursor() as cursor: now = time.time() sql = "SELECT SUM(qty) AS total_qty, SUM(total) AS total_amt, COUNT(statement_id) AS total_rows FROM accountingflat.dig_sales_detail;" cursor.execute(sql) post_query = time.time() logger.info(f"Query time for {sql} is {post_query - now}\n") result = cursor.fetchone() formatted_result = { "total_qty": int(result["total_qty"]), "total_amt": float(result["total_amt"]), "total_rows": result["total_rows"], } logger.info(f"Result: {formatted_result}") if connection.show_warnings(): logger.warning(f"Warnings: {connection.show_warnings()}") connection.close() if __name__ == "__main__": main()