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


Python MySQL.getInsertId方法代码示例

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


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

示例1: createShortUrl

# 需要导入模块: from MySQL import MySQL [as 别名]
# 或者: from MySQL.MySQL import getInsertId [as 别名]
def createShortUrl(url):
	urlId = 0
	db = MySQL()
	urlhash = Utils.MD5(url)

	# first find
	urlInstance = db.get(r"SELECT * FROM `short_urls` WHERE `hash`=%s", urlhash)
	if urlInstance:
		urlId = urlInstance['id']

	# create if don't found
	if urlId == 0:
		result = db.save(r"INSERT INTO `short_urls` (`hash`, `url`) VALUES (%s,%s)", (urlhash, url))
		urlId = db.getInsertId()
		db.end()

	return __short_url_prefix + NumberCodec.encode(urlId)
开发者ID:xaccc,项目名称:videoapiserver,代码行数:19,代码来源:ShortUrlService.py

示例2: video_create

# 需要导入模块: from MySQL import MySQL [as 别名]
# 或者: from MySQL.MySQL import getInsertId [as 别名]
def video_create(data):
	"""
	设置视频信息
	方法:
		video_create
	参数:
		UserKey[string] –用户登录后的会话ID。
		UploadId[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'])

	fileName = "%s/%s" % (uploadDirectory, data['UploadId'])

	db = MySQL()
	newId = Utils.UUID()
	media = MediaProbe(fileName)

	# media.createTime()
	result = db.save("""INSERT INTO `video` (`id`, `upload_id`, `owner_id`, `duration`, `video_width`, `video_height`, `video_bitrate`, `title`, `author`, `create_date`, `category`, `describe`, `tag`, `lbs_addr`, `lbs_lon`, `lbs_lat`) 
						VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s)""",
					(newId, data['UploadId'], userId, media.duration(), media.videoWidth(), media.videoHeight(), media.videoBitrate(), 
					data.get('Title', ''),
					data.get('Author', ''),
					data.get('CreateTime', media.createTime()),
					data.get('Category', ''),
					data.get('Describe', ''),
					data.get('Tag', ''),
					data.get('AddrStr', None),
					data.get('Longitude', None),
					data.get('Latitude', None)))
	db.end()

	# 截图
	destFileName = "%s/%s.jpg" % (videoDirectory, newId)
	Transcoder.VideoPoster(fileName, destFileName)

	# post transcode task
	# 原清晰度
	if media.videoCodec() == 'h264' and media.audioCodec() == 'aac' :
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '.mp4',
							media.videoWidth(),
							media.videoHeight(),
							media.videoBitrate(),
							'copy',
							media.audioChannels(),
							media.audioBitrate(),
							'copy'))
		taskId = db.getInsertId()
		db.end()
	else:
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '.mp4',
							media.videoWidth(),
							media.videoHeight(),
							media.videoBitrate(),
							TranscodeTemplates.HD['video_codec'],
							media.audioChannels(),
							media.audioBitrate(),
							TranscodeTemplates.HD['audio_codec'] ))
		taskId = db.getInsertId()
		db.end()

	# 高清
	if media.supportHD() and not media.DefinitionIsHD():
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '_hd.mp4', 
							int(TranscodeTemplates.HD['video_width']), 
							int(TranscodeTemplates.HD['video_width']) / media.videoAspect(),
							TranscodeTemplates.HD['video_bitrate'], 
							TranscodeTemplates.HD['video_codec'],
							TranscodeTemplates.HD['audio_channel'],
							TranscodeTemplates.HD['audio_bitrate'],
							TranscodeTemplates.HD['audio_codec'] ))
		taskId = db.getInsertId()
		db.end()

	# 标清
	if media.supportSD() and not media.DefinitionIsSD():
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '_sd.mp4', 
							int(TranscodeTemplates.SD['video_width']), 
							int(TranscodeTemplates.SD['video_width']) / media.videoAspect(),
							TranscodeTemplates.SD['video_bitrate'], 
#.........这里部分代码省略.........
开发者ID:xaccc,项目名称:videoapiserver,代码行数:103,代码来源:VideoService.py

示例3: MediaProbe

# 需要导入模块: from MySQL import MySQL [as 别名]
# 或者: from MySQL.MySQL import getInsertId [as 别名]
	newId = video['id']
	media = MediaProbe(uploadFileName)

	# 原清晰度
	if media.videoCodec() == 'h264' and media.audioCodec() == 'aac' :
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '.mp4',
							media.videoWidth(),
							media.videoHeight(),
							media.videoBitrate(),
							'copy',
							media.audioChannels(),
							media.audioBitrate(),
							'copy'))
		taskId = db.getInsertId()
		db.end()
	else:
		result = db.save("""INSERT INTO `video_transcode` (`video_id`, `file_name`, `video_width`, `video_height`, `video_bitrate`, `video_codec`, `audio_channels`, `audio_bitrate`, `audio_codec`) 
							VALUES (%s,%s,%s,%s,%s, %s,%s,%s,%s)""",
						(newId, newId + '.mp4',
							media.videoWidth(),
							media.videoHeight(),
							media.videoBitrate(),
							TranscodeTemplates.HD['video_codec'],
							media.audioChannels(),
							media.audioBitrate(),
							TranscodeTemplates.HD['audio_codec'] ))
		taskId = db.getInsertId()
		db.end()
开发者ID:xaccc,项目名称:videoapiserver,代码行数:32,代码来源:upgrade.py


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