Add simp read/write sql

This commit is contained in:
wqy
2022-09-24 23:00:20 +08:00
parent 1938d3d522
commit 46df1beedb

View File

@@ -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