当前位置: 首页>>代码示例>>Python>>正文


Python Utils.execute_id方法代码示例

本文整理汇总了Python中utils.Utils.execute_id方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.execute_id方法的具体用法?Python Utils.execute_id怎么用?Python Utils.execute_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Utils的用法示例。


在下文中一共展示了Utils.execute_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initLocations

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import execute_id [as 别名]
	def initLocations(self):


		self.home_id = str(Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) VALUES(%s, %s, %s, %s)""", (self.home[0],self.home[1],self.home[2],self.home[3])))
		self.work_id = str(Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) VALUES(%s, %s, %s, %s)""", (self.work[0],self.work[1],self.work[2],self.work[3])))
		self.extra_id = str(Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) VALUES(%s, %s, %s, %s)""", (self.extra[0],self.extra[1],self.extra[2],self.extra[3])))

		for i in self.routes:
			self.route_ids.append(str(Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) VALUES(%s, %s, %s, %s)""", (i[0], i[1],i[2],i[3]))))
		
		return self.home_id
开发者ID:petryjc,项目名称:WhatDoIDo,代码行数:13,代码来源:simpleCyclesScript.py

示例2: add_data2

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import execute_id [as 别名]
def add_data2(o,occurances):
  location_id = Utils.execute_id("""INSERT INTO Locations(address) VALUES('The place I am')""",())
  user_id = Utils.query("""SELECT user_id
                            FROM User_Sessions
                            WHERE session_token = %s;""", (o.loginResult['token']))

  event_id= Utils.execute_id("""INSERT INTO Events(event_type,user_id,name,location_id,locked,deleted)
                                VALUES ('cycle',%s,'test cycle',%s,TRUE,FALSE);""",
                                (user_id[0]["user_id"], location_id))

  Utils.execute("""INSERT INTO Cyclical_Events(event_id, cycle_type, occurances)
                          VALUES(%s,'weekly',%s)""", (event_id, json.JSONEncoder().encode(occurances)))

  return {"location_id" : location_id, "event_id" : event_id }
开发者ID:petryjc,项目名称:WhatDoIDo,代码行数:16,代码来源:unittests.py

示例3: getLocationID

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import execute_id [as 别名]
	def getLocationID(self, location):
		
		loc_id = Utils.query("SELECT location_id FROM Locations WHERE place = %s", (location[3]))
		
		if len(loc_id) > 0:
			return loc_id[0]["location_id"]
		else:
			return Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) 
			VALUES(%s, %s, %s, %s)""", (location[0], location[1], location[2], location[3]))
开发者ID:petryjc,项目名称:WhatDoIDo,代码行数:11,代码来源:testDataScript.py

示例4: add

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import execute_id [as 别名]
	def add(self):
		body = json.loads( cherrypy.request.body.read() )
    
		check = Utils.arg_check(body, ['token', 'latitude', 'longitude'])	
		if (check[0]):
			return check[1]
		
		user_check = Utils.validate_user(body["token"])
		if(user_check[0]):
			return user_check[1]
		user_id = user_check[1]
		
		base = "http://maps.googleapis.com/maps/api/geocode/json?"
		params = "latlng={lat},{lon}&sensor={sen}".format(
			lat=body['latitude'],
			lon=body['longitude'],
			sen=True
		)
		url = "{base}{params}".format(base=base, params=params)
		response = requests.get(url)
		
		if (response):
			content = response.json()
			if (content and content['results'] and content['results'][0] and content['results'][0]['formatted_address']):
				savedLocations = Utils.query("""SELECT * FROM Locations WHERE address = %s""",
							    (content['results'][0]['formatted_address']))
				#print savedLocations
				if (len(savedLocations) == 1):
					location_id = savedLocations[0]["location_id"]
				elif (len(savedLocations) > 1):
					return json.JSONEncoder().encode( Utils.status_more( 34, "Inconsistet database" ) )
				else:
					location_id  = Utils.execute_id("""INSERT INTO Locations(latitude, longitude, address, place) 
							 VALUES(%s, %s, %s, %s)""", 
							(body["latitude"], body["longitude"], content['results'][0]['formatted_address'], "I don't know"))
				if (location_id  != -1):
					previousUserLocation = Utils.query("""SELECT location_id FROM Users_Locations 
													WHERE user_id = %s 
													ORDER BY time DESC LIMIT 1""", (user_id))
					is_route = False
					if previousUserLocation:
						previousLocation = Utils.query("""SELECT * FROM Locations WHERE location_id = %s""", (previousUserLocation[0]["location_id"]))
					
						if len(previousLocation) == 1 and self.checkDistance(previousLocation[0]["latitude"], previousLocation[0]["longitude"],body["latitude"],body["longitude"]) == 1: 
							is_route = True
					Utils.execute("""INSERT INTO Users_Locations(user_id, location_id, time, is_route) 
							VALUES(%s, %s, %s, %s)""",
							(user_id, location_id, datetime.now(), is_route))
					return json.JSONEncoder().encode( Utils.status_more( 0, "OK" ) )
			return json.JSONEncoder().encode( Utils.status_more( 35, "Could not save to database" ) )

		return json.JSONEncoder().encode( Utils.status_more( 33, "Could not retrieve location information" ) )
开发者ID:petryjc,项目名称:WhatDoIDo,代码行数:54,代码来源:location.py


注:本文中的utils.Utils.execute_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。