Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -175,6 +175,7 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
|
|
175 |
async with AsyncSession(sms_resource["engine"]) as session:
|
176 |
code = 1
|
177 |
error = None
|
|
|
178 |
existing = await session.get(instance.__class__, idx)
|
179 |
|
180 |
# For add action, do db operation if instance is not existing. Other actions, do db operation if instance exists in db
|
@@ -184,8 +185,7 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
|
|
184 |
if checker:
|
185 |
if action == "delete":
|
186 |
await session.delete(instance)
|
187 |
-
await session.commit()
|
188 |
-
result = None
|
189 |
else: # add or update use add
|
190 |
session.add(instance) # Not asynchronous
|
191 |
await session.commit()
|
|
|
175 |
async with AsyncSession(sms_resource["engine"]) as session:
|
176 |
code = 1
|
177 |
error = None
|
178 |
+
result = None
|
179 |
existing = await session.get(instance.__class__, idx)
|
180 |
|
181 |
# For add action, do db operation if instance is not existing. Other actions, do db operation if instance exists in db
|
|
|
185 |
if checker:
|
186 |
if action == "delete":
|
187 |
await session.delete(instance)
|
188 |
+
await session.commit()
|
|
|
189 |
else: # add or update use add
|
190 |
session.add(instance) # Not asynchronous
|
191 |
await session.commit()
|