aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/query_tools.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-07-19 09:41:07 +0300
committerFrederick Muriuki Muriithi2023-07-19 09:41:07 +0300
commit82722fefd007edbddf08175686570e2ed307097e (patch)
tree36fdbe31e7962dea2b1df8dcac032e5e61a353ee /gn3/db/query_tools.py
parent9b2f5b8bf533a8ed360752cf9199f83bdd4454a3 (diff)
downloadgenenetwork3-82722fefd007edbddf08175686570e2ed307097e.tar.gz
Extract reusable code to separate module
Extract the reusable function into a separate `query_tools` module for use in other modules.
Diffstat (limited to 'gn3/db/query_tools.py')
-rw-r--r--gn3/db/query_tools.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/gn3/db/query_tools.py b/gn3/db/query_tools.py
new file mode 100644
index 0000000..2e3dd84
--- /dev/null
+++ b/gn3/db/query_tools.py
@@ -0,0 +1,7 @@
+"""Functions and utilities to use when generating queries"""
+
+def mapping_to_query_columns(mapping_dict: dict[str, str]) -> tuple[str, ...]:
+ """
+ Internal function to convert mapping dicts into column clauses for queries.
+ """
+ return tuple(f"{tcol} as {dcol}" for dcol, tcol in mapping_dict.items())