Add simp read/write sql
This commit is contained in:
@@ -4,12 +4,17 @@ from .operation import *
|
|||||||
from .change_set import ChangeSet
|
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:
|
with conn[name].cursor(row_factory=dict_row) as cur:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
return cur.fetchone()
|
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:
|
def decorate(value: str | None, type: str, optional: bool) -> str:
|
||||||
if optional:
|
if optional:
|
||||||
value = 'NULL' if value == None else value
|
value = 'NULL' if value == None else value
|
||||||
|
|||||||
Reference in New Issue
Block a user