本文整理匯總了Python中MySQL.MySQL.update方法的典型用法代碼示例。如果您正苦於以下問題:Python MySQL.update方法的具體用法?Python MySQL.update怎麽用?Python MySQL.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySQL.MySQL
的用法示例。
在下文中一共展示了MySQL.update方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: space_reindex
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def space_reindex(data):
userId = UserService.user_id(data['UserKey'])
db = MySQL()
spaceId = data.get('Id', '')
afterId = data.get('After', '')
index = []
spaceListInstance = db.list('SELECT * FROM `space` WHERE `user_id` = %s ORDER BY `index` ASC', (userId))
for space in spaceListInstance:
index.append(space['id'])
if not spaceId in index:
raise Exception('空間不存在')
index.remove(spaceId)
if afterId == 'HEAD':
index.insert(0, spaceId)
elif afterId in index:
index.insert(index.index(afterId) + 1, spaceId)
else:
index.append(spaceId)
for i,value in enumerate(index):
db.update("UPDATE `space` SET `index` = %s WHERE `id` = %s", (i, value))
db.end()
return {
'Id': spaceId,
}
示例2: StartTranscodeService
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def StartTranscodeService():
import socket
hostname = socket.gethostname()
pid = os.getpid()
f = open('transcoder.pid', 'wb')
f.write(str(pid))
f.close()
signal.signal(signal.SIGTERM, sig_handler)
signal.signal(signal.SIGINT, sig_handler)
db = MySQL()
transcoder = Transcoder(Started = __Started, Progress = __Progress, Finished = __Finished, Error = __Error)
uploadDirectory = applicationConfig.get('Server','Upload')
videoDirectory = applicationConfig.get('Video','SavePath')
if not os.path.exists(videoDirectory):
os.makedirs(videoDirectory)
while True:
if __shutdown.wait(1):
break; # exit thread
if transcoder.Count() > 0:
continue; # wait process
taskList = db.list('SELECT * FROM `video_transcode` WHERE `transcoder` IS NULL ORDER BY `id` LIMIT 0,1 FOR UPDATE')
for task in taskList:
db.update("UPDATE `video_transcode` set `transcoder` = %s WHERE `id` = %s", (hostname, task['id']))
db2 = MySQL()
videoInstance = db2.get("SELECT * FROM `video` WHERE `id`=%s", (task['video_id']))
if videoInstance:
fileName = "%s/%s" % (uploadDirectory, videoInstance['upload_id'])
destFileName = "%s/%s" % (videoDirectory, task['file_name'])
transcoder.addTask({
'file' : fileName,
'video_codec' : task['video_codec'],
'video_bitrate' : task['video_bitrate'],
'video_width' : task['video_width'],
'video_height' : task['video_height'],
'audio_codec' : task['audio_codec'],
'audio_channels': task['audio_channels'],
'audio_bitrate' : task['audio_bitrate'],
'output' : destFileName,
}, arg = task['id'])
db.end()
while transcoder.Count() > 0:
theading.sleep(1)
print '.'
示例3: invite_pocket
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def invite_pocket(data):
userId = UserService.user_id(data['UserKey'])
db = MySQL()
result = db.update("UPDATE `invite` SET `is_pocket` = 1, `pocket_date` = now() WHERE `user_id` = %s AND `id` = %s AND `is_pocket` = 0", (userId, data.get('Code', None)))
db.end()
if result > 0:
return {
'Code': data.get('Code', None)
}
else:
raise Exception('邀請碼不存在或已處理')
示例4: space_rename
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def space_rename(data):
userId = UserService.user_id(data['UserKey'])
db = MySQL()
result = db.update("UPDATE `space` SET `name` = %s WHERE `id` = %s AND `user_id` = %s", (data.get('Name', ''), data.get('Id', ''), userId))
db.end()
if result > 0:
return {
'Id': data.get('Id', ''),
'Name': data.get('Name', ''),
}
else:
raise Exception('更新失敗或空間不存在')
示例5: video_update
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def video_update(data):
"""
更新視頻信息
參數:
UserKey[string] –用戶登錄後的會話ID。
VID[string] – 視頻ID
Title[string] – 視頻標題
Author[string] – 分享者/創作者名稱
CreateTime[date] – 創作日期
Category[string] – 視頻分類
Describe[string] – 視頻描述
Tag[string] – 視頻標簽,標簽內容有半角“,”(逗號)分割
AddrStr[string] - 視頻位置信息
Longitude[float] - 視頻位置 - 經度
Latitude[float] - 視頻位置 - 緯度
返回值:
VID[string] – 視頻ID
"""
userId = UserService.user_id(data['UserKey'])
videoId = data.get('VID', '')
db = MySQL()
db.update("UPDATE `video` set `title` = %s, `author` = %s, `create_date` = %s, `category` = %s, `describe` = %s, `tag` = %s WHERE `id` = %s AND `owner_id` = %s ", (
data.get('Title', ''),
data.get('Author', ''),
data.get('CreateTime', ''),
data.get('Category', ''),
data.get('Describe', ''),
data.get('Tag', ''),
videoId,
userId))
db.end()
return data.get('VID', '')
示例6: invite_deal
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def invite_deal(data):
"""
接受邀請
參數:
UserKey[string] – 用戶會話ID
Code[string] – 邀請碼
返回值:
Code[string] – 邀請碼
"""
userId = UserService.user_id(data['UserKey'])
db = MySQL()
result = db.update("UPDATE `invite` SET `is_deal` = 1, `deal_date` = now(), `deal_user_id` = %s WHERE `id` = %s AND `is_deal` = 0", (userId, data.get('Code', None)))
db.end()
if result > 0:
return {
'Code': data.get('Code', None)
}
else:
raise Exception('邀請碼不存在或已處理')
示例7: space_authorize
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def space_authorize(data):
userId = UserService.user_id(data['UserKey'])
spaceInstance = space_get(data.get('Id', ''))
if userId == spaceInstance['user_id']:
allowEdit = min(1, max(0, int(data.get('AllowEdit', 0))))
db = MySQL()
authorizeUser = UserService.user_get(data.get('UserId', ''))
result = db.update("REPLACE INTO `space_authorize` (`space_id`, `user_id`, `allow_edit`) VALUES (%s,%s,%s)",
(data.get('Id', ''), data.get('UserId', ''), allowEdit))
db.end()
return {
'Id': spaceInstance['id'],
'Name': spaceInstance['name'],
'UserId': authorizeUser['id'],
'UserName': authorizeUser['name'],
'AllowEdit': allowEdit,
}
else:
raise Exception('沒有權限或空間不存在')
示例8: space_res_relation
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def space_res_relation(data):
userId = UserService.user_id(data['UserKey'])
db = MySQL()
# TEST AUTHORIZE
if __test_auth_edit(userId, data.get('Id', '')) > 0:
newId = Utils.UUID()
result = db.update("INSERT INTO `space_resource` (`id`, `space_id`, `owner_id`, `res_type`, `res_id`, `order_field1`, `order_field2`, `order_field3`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
(newId, data.get('Id', ''), userId, data.get('ResType', ''), data.get('ResId', ''), data.get('OrderField1', None), data.get('OrderField2', None), data.get('OrderField3', None)))
db.end()
if result > 0:
return {
'Id': data.get('Id', ''),
'ResType': data.get('ResType', ''),
'ResId': data.get('ResId', ''),
}
else:
raise Exception('更新失敗或空間不存在')
else:
raise Exception('沒有權限或空間不存在')
示例9: space_res_order
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def space_res_order(data):
userId = UserService.user_id(data['UserKey'])
db = MySQL()
# TEST AUTHORIZE
if __test_auth_edit(userId, data.get('Id', '')) > 0:
newId = Utils.UUID()
result = db.update("UPDATE `space_resource` SET `order_field1`=%s, `order_field2`=%s, `order_field3`=%s WHERE `space_id`=%s AND `res_type`=%s AND `res_id`=%s",
(data.get('OrderField1', None), data.get('OrderField2', None), data.get('OrderField3', None), data.get('Id', ''), userId, data.get('ResType', ''), data.get('ResId', '')))
db.end()
if result > 0:
return {
'Id': data.get('Id', ''),
'ResType': data.get('ResType', ''),
'ResId': data.get('ResId', ''),
}
else:
raise Exception('更新失敗或空間不存在')
else:
raise Exception('沒有權限或空間不存在')
示例10: arrived
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def arrived(notifyId):
db = MySQL()
db.update("UPDATE `user_notify` SET `arrived_date` = NOW(), `arrived` = 1 WHERE `id` = %s", (notifyId))
db.end()
示例11: user_password
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def user_password(data):
userId = user_id(data['UserKey'])
db = MySQL()
db.update("UPDATE `user` SET `password` = %s WHERE `id` = %s", ( Utils.MD5(data['Password']), userId ))
db.end()
return userId
示例12: __Finished
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def __Finished(transcodeId):
print "[%s] [Finished] %s ..." % (datetime.now().strftime('%Y-%m-%dT%H:%M:%S'), transcodeId)
db = MySQL()
db.update("UPDATE `video_transcode` set `is_ready` = 1, `progress` = 1 WHERE `id` = %s", (transcodeId))
db.end()
pass
示例13: __Progress
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def __Progress(transcodeId, percent, fps):
db = MySQL()
db.update("UPDATE `video_transcode` set `update_time` = now(), `progress` = %s WHERE `id` = %s", (float(percent), transcodeId))
db.end()
pass
示例14: __Started
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import update [as 別名]
def __Started(transcodeId):
db = MySQL()
db.update("UPDATE `video_transcode` set `transcode_time` = now(), `progress` = 0 WHERE `id` = %s", (transcodeId))
db.end()
print "[%s] [Start] %s ..." % (datetime.now().strftime('%Y-%m-%dT%H:%M:%S'), transcodeId)
pass