(20241010) Almost ready for deployment.

This commit is contained in:
2024-10-10 11:44:45 +05:30
13 changed files with 87 additions and 23 deletions
+21 -11
View File
@@ -96,7 +96,8 @@ class AsyncMySQL:
"""
A class to work with SQL-based databases. Originally meant to only invoke stored procedures and retrieve them as
JSON-like structures (list or dict).
JSON-like structures (list or dict). The format for the results was very specific to our use case for serving
Bicree's requirement. This may not serve your requirement at all.
:param pool_size: The number of connections to maintain n a pool.
:param args: Any arguments to pass. Not used.
:param kwargs: Pass the connection configuration from here.
@@ -207,8 +208,6 @@ class AsyncMySQL:
await asyncio.sleep(backoff_seconds)
backoff_seconds = backoff_seconds * backoff_multiplier
print("LEN:", len(results))
# If the results are blank:
if len(results) == 0: return {
"status": results[0][0]["status"],
@@ -238,9 +237,6 @@ class AsyncMySQL:
formatted_results["seconds"] = time.perf_counter() - start_ts
# Done here:
print(f"{procedure_name}:")
print(json.to_string(formatted_results))
print("\n")
if return_exception: return formatted_results, exception
else: return formatted_results
@@ -274,12 +270,20 @@ if __name__ == "__main__":
:return: None.
"""
# cred_json = {
# "host": "del.ditscentre.in",
# "user": "bicree",
# "port": 3306,
# "password": "9c3b2808a4aa281129d399fe09e69b53",
# "database": "bicree"
# }
cred_json = {
"host": "del.ditscentre.in",
"user": "bicree",
"user": "caOffice",
"port": 3306,
"password": "9c3b2808a4aa281129d399fe09e69b53",
"database": "bicree"
"password": "jstArchon",
"database": "caOffice"
}
db_conn = AsyncMySQL(
@@ -299,10 +303,16 @@ if __name__ == "__main__":
# )
# )
# result = await db_conn.call_procedure_and_get_json(
# procedure_name = "listSummary",
# procedure_args = ("bd7a6e53-1345-11ef-940c-0cc47a84a0bb",)
# )
result = await db_conn.call_procedure_and_get_json(
procedure_name = "listSummary",
procedure_args = ("bd7a6e53-1345-11ef-940c-0cc47a84a0bb",)
procedure_name = "campaign_activity_report",
procedure_args = (10000000,)
)
print("RESULT:", json.to_string(result, default = str))
start_time = time.time()