Add filtering option
This commit is contained in:
parent
c37c93d0d4
commit
e25a5aae20
1 changed files with 11 additions and 1 deletions
|
|
@ -101,7 +101,6 @@ class DBConnector:
|
|||
).format(Literal(table_name))
|
||||
with self.connection() as conn:
|
||||
result = conn.execute(stmt).fetchone()
|
||||
print(result)
|
||||
return False if result is None else result["exists"]
|
||||
|
||||
def createTable(
|
||||
|
|
@ -149,6 +148,17 @@ class DBConnector:
|
|||
with self.connection() as conn:
|
||||
return conn.execute(stmt).fetchall()
|
||||
|
||||
def filterFromTable(
|
||||
self, table_name: str, columns: list[str], where: list[ColumnCondition]
|
||||
) -> list[dict[str, Any]]:
|
||||
stmt = SQL("SELECT {} FROM {} WHERE {}").format(
|
||||
SQL(", ").join(map(lambda c: Identifier(c), columns)),
|
||||
Identifier(table_name),
|
||||
SQL(", ").join(map(lambda cp: cp.sql(), where)),
|
||||
)
|
||||
with self.connection() as conn:
|
||||
return conn.execute(stmt).fetchall()
|
||||
|
||||
def updateDataInTable(
|
||||
self, table_name: str, columns: list[ColumnUpdate], where: list[ColumnCondition]
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue