本文整理汇总了Python中Model.Model.fetchOneRow方法的典型用法代码示例。如果您正苦于以下问题:Python Model.fetchOneRow方法的具体用法?Python Model.fetchOneRow怎么用?Python Model.fetchOneRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.fetchOneRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getNeighbourgFromDirection
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fetchOneRow [as 别名]
def getNeighbourgFromDirection(idArea, direction):
"""
area.model.getNeighbourgFromDirection(idArea, direction) -> dict()
Returns the neighbourg of the area given in arguments from a given
direction.
@param idArea integer id of the reference area
@direction string direction (from the reference area) of the area to
return, must be a value of area.directions.
@return dict informations of the found area, empty dict if not found.
"""
if direction not in (directions):
raise exception('Unknown direction')
query = "\
SELECT\
ad.id_area,\
ad.id_region,\
ad.id_next_area_north,\
ad.id_next_area_east,\
ad.id_next_area_south,\
ad.id_next_area_west\
FROM\
area AS ad\
JOIN area AS ap ON ad.id_area = ap.id_next_area_%s\
WHERE\
ap.id_area = ?\
" % direction
return Model.fetchOneRow(query, [idArea])
示例2: getSurroundingAreas
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import fetchOneRow [as 别名]
def getSurroundingAreas(idArea):
"""
area.getSurroundingAreas(idArea) -> dict()
Return the available neighbourg areas of the area given in argument.
@param idArea integer id of the reference area
@return dict a list of directions, with for each direction, True if
there is an area in this direction, False else.
"""
query = "\
SELECT\
id_next_area_north IS NOT NULL AS north,\
id_next_area_south IS NOT NULL AS south,\
id_next_area_east IS NOT NULL AS east,\
id_next_area_west IS NOT NULL AS west\
FROM\
area\
WHERE\
id_area = ?\
"
return Model.fetchOneRow(query, [idArea])