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


Python Commit.loadFromDatabase方法代码示例

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


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

示例1: find

# 需要导入模块: from commit import Commit [as 别名]
# 或者: from commit.Commit import loadFromDatabase [as 别名]
	def find(query, components):
		conn = DB.getConn()
		c = conn.cursor()
		
		c.execute(query, components)
                commitrows = c.fetchall()
                commitfiles = []

                if commitrows:
                        allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])

                        #This is poor practice, but we assured ourselves the value is composed only of ints first
                        DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitfiles = c.fetchall()

                        DB.execute(c, "SELECT * from " + DB.commitkeyword._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitkeywords = c.fetchall()

                commits = []
                for i in commitrows:
                        r = Repo()
                        r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2],
                                i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])

                        files = [file[DB.commitfile.file] for file in commitfiles
                                if file[DB.commitfile.commitid] == i[DB.commit.id]]
                        keywords = [keyword[DB.commitkeyword.keyword] for keyword in commitkeywords
                                    if keyword[DB.commitkeyword.commitid] == i[DB.commit.id]]

                        c = Commit()
                        c.loadFromDatabase(r, i, files, keywords)

                        commits.append(c)

                return commits
开发者ID:deepcell,项目名称:code-audit-feed,代码行数:37,代码来源:databaseQueries.py

示例2: findByKeywords

# 需要导入模块: from commit import Commit [as 别名]
# 或者: from commit.Commit import loadFromDatabase [as 别名]
	def findByKeywords(keywords):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if keywords:
			keywordsTree = KeywordsParser(keywords)
			getcommitsSQL += "LEFT OUTER JOIN " + DB.commitkeyword._table + " ck " + \
							 "	ON c.id = ck.commitid "
			whereClause, components = keywordsTree.getWhereClause("ck.keyword", "r.tagname", "r.maturity")
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		c.execute(getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			c.execute("SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:48,代码来源:databaseQueries.py

示例3: findByIDs

# 需要导入模块: from commit import Commit [as 别名]
# 或者: from commit.Commit import loadFromDatabase [as 别名]
	def findByIDs(project, uniqueid):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if project and uniqueid:
			whereClause += "AND r.tagname = %s AND c.uniqueid = %s "
			components = [project, uniqueid]
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		DB.execute(c, getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:46,代码来源:databaseQueries.py


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