Пример #1
0
	def get_works():
		query = '''SELECT work.WorkID, work.Title, work.Content, work.AuthorID, work.DynastyID, author.Author, dynasty.Dynasty\n
			FROM work, author, dynasty\n
			WHERE work.AuthorID = author.AuthorID\n
			AND work.DynastyID = dynasty.DynastyID'''
		cursor.execute(query)
		return cursor.fetchall()		
Пример #2
0
    def get_users_love_work(work_id):
        query = '''SELECT user.UserID, user.Name, user.Avatar\n
			FROM love, user\n
			WHERE love.WorkID = %d\n
			AND love.UserID = user.UserID\n''' % work_id
        cursor.execute(query)
        return cursor.fetchall()
Пример #3
0
    def get_comments_by_review(review_id):
        query = '''SELECT comment.CommentID, comment.Comment, comment.Time, user.UserID, user.Name, user.Avatar\n
			FROM comment, user\n
			WHERE comment.UserID = user.UserID
			AND comment.ReviewID = %d''' % review_id
        cursor.execute(query)
        return cursor.fetchall()
Пример #4
0
	def get_users_love_work(work_id):
		query = '''SELECT user.UserID, user.Name, user.Avatar\n
			FROM love, user\n
			WHERE love.WorkID = %d\n
			AND love.UserID = user.UserID\n''' % work_id
		cursor.execute(query)
		return cursor.fetchall()
Пример #5
0
    def get_hot_reviews():
        query = '''SELECT review.ReviewID, review.Title, review.Content, review.Time, user.UserID, user.Name, user.Avatar, work.WorkID, work.Title AS WorkTitle, work.Content AS WorkContent, author.Author\n
			FROM review, user, work, author\n
			WHERE review.UserID = user.UserID\n
			AND review.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID\n'''
        cursor.execute(query)
        return cursor.fetchall()
Пример #6
0
	def get_authors_by_random(authorsNum):
		query = '''SELECT *\n
			FROM author, dynasty\n
			WHERE author.DynastyID = dynasty.DynastyID\n
			ORDER BY RAND()\n
			LIMIT %d''' % authorsNum
		cursor.execute(query)
		return cursor.fetchall()
Пример #7
0
    def get_authors_by_random(authorsNum):
        query = '''SELECT *\n
			FROM author, dynasty\n
			WHERE author.DynastyID = dynasty.DynastyID\n
			ORDER BY RAND()\n
			LIMIT %d''' % authorsNum
        cursor.execute(query)
        return cursor.fetchall()
Пример #8
0
	def get_hot_reviews():
		query = '''SELECT review.ReviewID, review.Title, review.Content, review.Time, user.UserID, user.Name, user.Avatar, work.WorkID, work.Title AS WorkTitle, work.Content AS WorkContent, author.Author\n
			FROM review, user, work, author\n
			WHERE review.UserID = user.UserID\n
			AND review.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID\n'''
		cursor.execute(query)
		return cursor.fetchall()	
Пример #9
0
	def get_works_by_user_love(user_id):
		query = '''SELECT work.WorkID, work.Title, work.Content, author.AuthorID, author.Author\n
			FROM love, user, work, author\n
			WHERE love.UserID = %d\n
			AND love.UserID = user.UserID\n
			AND love.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID''' % user_id
		cursor.execute(query)
		return cursor.fetchall()
Пример #10
0
	def get_works_by_random(worksNum):
		query = '''SELECT work.WorkID, work.Title, work.Content, work.AuthorID, work.DynastyID, author.Author, dynasty.Dynasty\n
			FROM work, author, dynasty\n
			WHERE work.AuthorID = author.AuthorID\n
			AND work.DynastyID = dynasty.DynastyID\n
			ORDER BY RAND()\n
			LIMIT %d''' % worksNum
		cursor.execute(query)
		return cursor.fetchall()
Пример #11
0
    def get_works_by_user_love(user_id):
        query = '''SELECT work.WorkID, work.Title, work.Content, author.AuthorID, author.Author\n
			FROM love, user, work, author\n
			WHERE love.UserID = %d\n
			AND love.UserID = user.UserID\n
			AND love.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID''' % user_id
        cursor.execute(query)
        return cursor.fetchall()
Пример #12
0
    def get_reviews_by_random(reviews_num):
        query = '''SELECT review.ReviewID, review.Title, review.Content, review.Time, user.UserID, user.Name, user.Avatar, work.WorkID, work.Title AS WorkTitle, work.Content AS WorkContent, author.Author\n
			FROM review, user, work, author\n
			WHERE review.UserID = user.UserID\n
			AND review.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID\n
			ORDER BY RAND()\n
			LIMIT %d''' % reviews_num
        cursor.execute(query)
        return cursor.fetchall()
Пример #13
0
	def get_reviews_by_random(reviews_num):
		query = '''SELECT review.ReviewID, review.Title, review.Content, review.Time, user.UserID, user.Name, user.Avatar, work.WorkID, work.Title AS WorkTitle, work.Content AS WorkContent, author.Author\n
			FROM review, user, work, author\n
			WHERE review.UserID = user.UserID\n
			AND review.WorkID = work.WorkID\n
			AND work.AuthorID = author.AuthorID\n
			ORDER BY RAND()\n
			LIMIT %d''' % reviews_num
		cursor.execute(query)
		return cursor.fetchall()
Пример #14
0
    def get_comments_by_review(review_id):
        query = (
            """SELECT comment.CommentID, comment.Comment, comment.Time, user.UserID, user.Name, user.Avatar\n
			FROM comment, user\n
			WHERE comment.UserID = user.UserID
			AND comment.ReviewID = %d"""
            % review_id
        )
        cursor.execute(query)
        return cursor.fetchall()
Пример #15
0
 def get_authors_by_name(name):
     query = "SELECT AuthorID, Author FROM author WHERE Author LIKE '%%%s%%'" % name
     cursor.execute(query)
     return cursor.fetchall()
Пример #16
0
	def get_authors_by_dynasty(dynastyID):
		query = '''SELECT *\n
			FROM author\n
			WHERE author.DynastyID = %d''' % dynastyID
		cursor.execute(query)
		return cursor.fetchall()
Пример #17
0
    def get_authors():
        query = '''SELECT *\n
			FROM author, dynasty\n
			WHERE author.DynastyID = dynasty.DynastyID'''
        cursor.execute(query)
        return cursor.fetchall()
Пример #18
0
    def get_authors_by_dynasty(dynastyID):
        query = '''SELECT *\n
			FROM author\n
			WHERE author.DynastyID = %d''' % dynastyID
        cursor.execute(query)
        return cursor.fetchall()
Пример #19
0
	def get_works_by_collection(collectionID):
		query = "SELECT * FROM work WHERE CollectionID = %d" % collectionID
		cursor.execute(query)
		return cursor.fetchall()
Пример #20
0
	def get_authors_by_name(name):
		query = "SELECT AuthorID, Author FROM author WHERE Author LIKE '%%%s%%'" % name
		cursor.execute(query)
		return cursor.fetchall()
Пример #21
0
	def get_works_by_author(authorID):
		query = "SELECT * FROM work WHERE AuthorID=%d" % authorID
		cursor.execute(query)
		return cursor.fetchall()
Пример #22
0
	def get_dynasties():
		query = "SELECT * FROM dynasty ORDER BY StartYear ASC";
		cursor.execute(query)
		return cursor.fetchall()
Пример #23
0
 def get_collections_by_author(authorID):
     query = "SELECT * FROM collection WHERE AuthorID = %d" % authorID
     cursor.execute(query)
     return cursor.fetchall()
Пример #24
0
	def get_products(num):
		query = "SELECT * FROM product LIMIT %d" % num
		cursor.execute(query)
		return cursor.fetchall()
Пример #25
0
	def get_authors():
		query = '''SELECT *\n
			FROM author, dynasty\n
			WHERE author.DynastyID = dynasty.DynastyID'''
		cursor.execute(query)
		return cursor.fetchall()
Пример #26
0
	def get_widgets(target_type, target_id):
		query = "SELECT * FROM widget WHERE Type = '%s' AND TargetID = %d ORDER BY PositionIndex ASC" % (target_type, target_id)
		cursor.execute(query)
		return cursor.fetchall()
Пример #27
0
	def get_collections_by_author(authorID):
		query = "SELECT * FROM collection WHERE AuthorID = %d" % authorID
		cursor.execute(query)
		return cursor.fetchall()