Skip to content

Commit 9b25bfc

Browse files
Delete all customers
1 parent 6df4787 commit 9b25bfc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/routers/customer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
INSERT_CUSTOMER = (
1010
"INSERT INTO CUSTOMERS(FIRST_NAME, LAST_NAME) VALUES (:first_name, :last_name)"
1111
)
12+
DELETE_ALL_CUSTOMERS = "TRUNCATE TABLE CUSTOMERS"
1213

1314
router = APIRouter()
1415

@@ -25,3 +26,9 @@ async def insert_customers(customers: list[Customer]) -> None:
2526
rows: list[dict[str, Any]] = list(map(lambda customer: vars(customer), customers))
2627
await database.execute_many(query=INSERT_CUSTOMER, values=rows)
2728
return None
29+
30+
31+
@router.delete("/customers/", status_code=status.HTTP_204_NO_CONTENT, tags=["users"])
32+
async def delete_all_customers() -> None:
33+
await database.execute(query=DELETE_ALL_CUSTOMERS)
34+
return None

0 commit comments

Comments
 (0)