當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.readDB方法代碼示例

本文整理匯總了Python中db.DB.readDB方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.readDB方法的具體用法?Python DB.readDB怎麽用?Python DB.readDB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在db.DB的用法示例。


在下文中一共展示了DB.readDB方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: channelRank

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
	def channelRank(self, idTimeSlice='SELECT last_value FROM "tbl_Timeslice_idTimeslice_seq"'):
		db=DB()
		query='SELECT count(*) "channelNewTwits", t."idChannel", c."channelName", c."channelNumber", c."channelImage" \
			FROM "tbl_Twit" t JOIN "tbl_Channel" c \
			ON t."idChannel" = c."idChannel" \
			JOIN "tbl_ChannelHashtag" ch \
			ON c."idChannel" = ch."idChannel" \
			AND ch."channelHastagEnabled"=TRUE \
			AND t."idTimeslice" = (%s)-1 \
			GROUP BY t."idChannel", c."channelName", c."channelNumber", c."channelImage" \
			ORDER BY "channelNewTwits" desc \
			LIMIT 10;' % (idTimeSlice)
		rank=db.readDB(query)
		i=0
		print '\n\n*********************'
		print '* Trending Channels *'
		print '*********************\n\n'
		while i<len(rank):
			twits=rank[i][0]
			idChannel=rank[i][1]
			channelName=rank[i][2]
			channelNumber=rank[i][3]
			print '%d) %s %s' % (i+1, channelName, channelNumber)
			i+=1
		print '\n\n'
		return rank
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:28,代碼來源:twitv.py

示例2: newTimeSlice

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
	def newTimeSlice(self):
		db=DB()
		query='INSERT INTO "tbl_TimeSlice" ("timeSliceDateFrom", "timeSliceTimeFrom") VALUES (current_date, current_time);'
		db.doDB(query)
		query='SELECT last_value FROM "tbl_Timeslice_idTimeslice_seq";'
		idTimeSlice=db.readDB(query)[0][0]
		return idTimeSlice
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:9,代碼來源:twitv.py

示例3: hashtags

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
	def hashtags(self):
		db=DB()
		#Query definition
		query = 'SELECT c."idChannel", c."channelNumber", c."channelName", ch."channelHashtagText" \
		FROM "tbl_Channel" c JOIN "tbl_ChannelHashtag" ch \
		ON c."idChannel"=ch."idChannel";'
		registros=db.readDB(query)

		#Local Array
		hashTags=[]

		#Reorganize DB response
		i=0
		add=1
		while i<len(registros):
			idChannel=registros[i][0]
			channelNumber=registros[i][1]
			channelName=registros[i][2]
			ht=registros[i][3]
			if registros[i][0]==registros[i-1][0] and i!=0:
				row.append(registros[i][3])
				add=0
			else:
				row = [i, idChannel, channelNumber, channelName, ht]
				add=1
			if add:
				hashTags.append(row)
			i+=1
		return hashTags
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:31,代碼來源:twitv.py

示例4: categoryDB

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
def categoryDB(keywords):
	print '%s\n\n\n' % keywords
	db = DB(host='190.215.44.18', port='5432', dbname='GLF', user='postgres', password='$martb0xTv')
	response = []
	for keyword in keywords:
		print keyword
		query = 'SELECT c."channelNumber", c."channelName", s."startDate", s."endDate", p."title", p."description", pc."mscName" \
			FROM "tbl_Channel" c, "tbl_Schedule" s, "tbl_Program" p, "tbl_ProgramCategory" pc, "tbl_KeywordCategory" kc, "tbl_Keyword" k \
			WHERE (c."idChannel"=s."idChannel" AND s."idProgram"=p."idProgram" AND p."idCategory"=pc."idCategory" AND pc."idCategory"=kc."idCategory" AND k."idKeyword"=kc."idKeyword" AND s."startDate">current_timestamp AND k."keywordName"=\''+keyword+'\') \
			ORDER BY "startDate" LIMIT 1;'
		#query = 'SELECT "categoryName" FROM "tbl_ProgramCategory" pc, "tbl_KeywordCategory" kc, "tbl_Keyword" k WHERE (pc."idCategory"=kc."idCategory" AND k."idKeyword"=kc."idKeyword" AND k."keywordName"=\''+keyword+'\');'
		try:
			programs = db.readDB(query)
		except:
			return response
		i=0
		progArr = []
		while i<len(programs):
			channelNumber=programs[i][0]
			channelName=programs[i][1]
			startDate=str(programs[i][2])
			endDate=str(programs[i][3])
			title=programs[i][4]
			description=programs[i][5]
			mscName=programs[i][6]
			progArr.append({'channelNumber':channelNumber, 'channelName':channelName, 'startDate':startDate, 'endDate':endDate, 'title':title, 'description':description, 'mscName':mscName})
			i+=1
		response.append(progArr)
	return response
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:31,代碼來源:server.py

示例5: lastTwit

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
	def lastTwit(self, hashTags):
		db=DB()
		query='SELECT "twitTwitId" FROM "tbl_Twit" WHERE "idChannel"=%d ORDER BY "idTwit" desc LIMIT 1;' % hashTags[1]
		lastTwit = db.readDB(query)
		try:
			lastTwit = lastTwit[0][0]
		except:
			lastTwit = ""
		lastTwit = str(lastTwit)
		return lastTwit
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:12,代碼來源:twitv.py

示例6: keywordsDB

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import readDB [as 別名]
def keywordsDB():
	db = DB(host='190.215.44.18', port='5432', dbname='GLF', user='postgres', password='$martb0xTv')
	query = 'SELECT "keywordName" FROM "tbl_Keyword";'
	keywords_db = db.readDB(query)
	keywords = [keyword[0].lower() for keyword in keywords_db]
	return keywords
開發者ID:alvarofaundez,項目名稱:SmartboxTv,代碼行數:8,代碼來源:server.py


注:本文中的db.DB.readDB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。