Implement DELETE method on /event
This commit is contained in:
parent
089e4a8dbd
commit
2690347bc8
1 changed files with 13 additions and 0 deletions
13
backend.py
13
backend.py
|
@ -186,6 +186,19 @@ WHERE events_id=%s;""", (id,))
|
||||||
def on_put(self, req, resp, id):
|
def on_put(self, req, resp, id):
|
||||||
self.insert_or_update(req, resp, id, """UPDATE events SET ( events_type, events_what, events_when, events_tags, events_geo) = (%s, %s, tstzrange(%s,%s,%s) , %s, %s) WHERE events_id = %s RETURNING events_id;""")
|
self.insert_or_update(req, resp, id, """UPDATE events SET ( events_type, events_what, events_when, events_tags, events_geo) = (%s, %s, tstzrange(%s,%s,%s) , %s, %s) WHERE events_id = %s RETURNING events_id;""")
|
||||||
|
|
||||||
|
def on_delete(self, req, resp, id):
|
||||||
|
standard_headers(resp)
|
||||||
|
db = db_connect()
|
||||||
|
cur = db.cursor()
|
||||||
|
cur.execute("""DELETE FROM events WHERE events_id = %s;""",(id,));
|
||||||
|
db.commit()
|
||||||
|
cur.close()
|
||||||
|
db.close()
|
||||||
|
if cur.rowcount:
|
||||||
|
resp.status = falcon.HTTP_204
|
||||||
|
else:
|
||||||
|
resp.status = falcon.HTTP_404
|
||||||
|
|
||||||
# falcon.API instances are callable WSGI apps
|
# falcon.API instances are callable WSGI apps
|
||||||
app = falcon.API()
|
app = falcon.API()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue