本文整理汇总了Python中app.models.state.State.delete方法的典型用法代码示例。如果您正苦于以下问题:Python State.delete方法的具体用法?Python State.delete怎么用?Python State.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.state.State
的用法示例。
在下文中一共展示了State.delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDown
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def tearDown(self):
#delete all from users
PlaceBook.delete().execute()
Place.delete().execute()
User.delete().execute()
City.delete().execute()
State.delete().execute()
示例2: setUp
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def setUp(self):
#connect to db and delete everyone in the users table
PlaceBook.delete().execute()
Place.delete().execute()
User.delete().execute()
City.delete().execute()
State.delete().execute()
示例3: handle_state_id
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def handle_state_id(state_id):
'''Select the state with the id from the database and store as the variable
`state` with a GET request method. Update the data of the particular state
with a PUT request method. This will take the parameters passed and update
only those values. Remove the state with this id from the database with
a DELETE request method.
Keyword arguments:
state_id: The id of the state from the database.
'''
try:
state = State.select().where(State.id == state_id).get()
except State.DoesNotExist:
return jsonify(msg="There is no state with this id."), 404
if request.method == 'GET':
return jsonify(state.to_dict()), 200
elif request.method == 'DELETE':
try:
state = State.delete().where(State.id == state_id)
except State.DoesNotExist:
raise Exception("There is no state with this id.")
state.execute()
return jsonify(msg="State deleted successfully."), 200
示例4: del_state
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def del_state(id):
id_check = State.select().where(State.id == id)
if not id_check:
return {'code': 404, 'msg': 'State not found'}, 404
item = State.delete().where(State.id == id)
item.execute()
return {'code': 200, 'msg': 'Deleted successfully'}, 200
示例5: delete_state
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def delete_state(state_id):
"""
Delete the given state
Deletes the given state in the database.
---
tags:
- State
parameters:
-
in: path
name: state_id
type: string
required: True
description: ID of the state
responses:
200:
description: State deleted successfully
schema:
$ref: '#/definitions/delete_amenity_delete_delete_200'
404:
description: State was not found
500:
description: Request could not be processed
"""
try:
''' Check that state_id exists '''
query = State.select().where(State.id == state_id)
if not query.exists():
raise LookupError('state_id')
''' Delete the given state '''
delete_state = State.delete().where(State.id == state_id)
delete_state.execute()
response = {}
response['code'] = 200
response['msg'] = "State account was deleted"
return response, 200
except LookupError as e:
abort(404)
except Exception as error:
abort(500)
示例6: setUp
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def setUp(self):
#connect to db and delete everyone in the cities table
City.delete().execute()
State.delete().execute()
示例7: tearDown
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def tearDown(self):
#delete all from cities
City.delete().execute()
State.delete().execute()
示例8: setUp
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def setUp(self):
#connect to db and delete everyone in the states table
State.delete().execute()
示例9: tearDown
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def tearDown(self):
#delete all from states
State.delete().execute()
示例10: tearDown
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import delete [as 别名]
def tearDown(self):
#delete all from places
Place.delete().execute()
User.delete().execute()
City.delete().execute()
State.delete().execute()