From 46df1beedb4428df961fbb918504d86f049c70ff Mon Sep 17 00:00:00 2001 From: wqy Date: Sat, 24 Sep 2022 23:00:20 +0800 Subject: [PATCH] Add simp read/write sql --- api/utility.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/utility.py b/api/utility.py index da09b0e..bbd1187 100644 --- a/api/utility.py +++ b/api/utility.py @@ -4,12 +4,17 @@ from .operation import * from .change_set import ChangeSet -def query(name: str, sql: str) -> Row | None: +def read(name: str, sql: str) -> Row | None: with conn[name].cursor(row_factory=dict_row) as cur: cur.execute(sql) return cur.fetchone() +def write(name: str, sql: str) -> None: + with conn[name].cursor() as cur: + cur.execute(sql) + + def decorate(value: str | None, type: str, optional: bool) -> str: if optional: value = 'NULL' if value == None else value