fix update query
This commit is contained in:
+4
-2
@@ -187,12 +187,14 @@ def insert_query(table_name: str, model: BaseModel) -> str:
|
|||||||
return f"INSERT INTO {table_name} ({fields}) VALUES ({values})"
|
return f"INSERT INTO {table_name} ({fields}) VALUES ({values})"
|
||||||
|
|
||||||
|
|
||||||
def update_query(table_name: str, model: BaseModel, where: str = "WHERE id = ?") -> str:
|
def update_query(
|
||||||
|
table_name: str, model: BaseModel, where: str = "WHERE id = :id"
|
||||||
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Generate an update query with placeholders for a given table and model
|
Generate an update query with placeholders for a given table and model
|
||||||
:param table_name: Name of the table
|
:param table_name: Name of the table
|
||||||
:param model: Pydantic model
|
:param model: Pydantic model
|
||||||
:param where: Where string, default to `WHERE id = ?`
|
:param where: Where string, default to `WHERE id = :id`
|
||||||
"""
|
"""
|
||||||
fields = []
|
fields = []
|
||||||
for field in model.dict().keys():
|
for field in model.dict().keys():
|
||||||
|
|||||||
Reference in New Issue
Block a user