示例#1
0
文件: query.py 项目: hoyinho/donald
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['donald']
    result = db.donald.find({'username':username})
    for post in result:
        post = transform.post(post)
    connection.close()
    return result
示例#2
0
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['donald']
    result = db.donald.find({'username': username})
    for post in result:
        post = transform.post(post)
    connection.close()
    return result
示例#3
0
文件: query.py 项目: elc1798/donald
def getPost(username, slug):
    connection = MongoClient()
    db = connection ['blog']
    result = db.donald.find({"username":username, "slug": slug})
    connection.close()
    if result.count() == 0:
        return False
    else:
        return transform.post(result[0])
示例#4
0
文件: query.py 项目: elc1798/donald
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['blog']
    result = db.donald.find({'username':username})
    connection.close()
    posts = []
    for post in result:
        posts.append(post)
    i = 0
    while(i < len(posts)):
        posts[i] = transform.post(posts[i])
        i+=1
    return posts
示例#5
0
文件: query.py 项目: elc1798/donald
def getAllPosts():
    connection = MongoClient()
    db = connection['blog']
    result = db.donald.find()
    connection.close()
    posts = []
    for post in result:
        posts.append(post)
    i = 0
    while(i < len(posts)):
        posts[i] = transform.post(posts[i])
        i+=1
    return posts
示例#6
0
文件: query.py 项目: hoyinho/donald
def getPost(username, slug):
    con = sqlite3.connect("donald.db")
    cur=con.cursor()

    sql = "SELECT * FROM posts WHERE username = \"%s\" AND slug = \"%s\"" % (username, slug)
    post = cur.execute(sql).fetchone()

    if post:
        post = transform.post(post)
        con.close()
        return post
    else:
        con.close()
        return False
示例#7
0
def getPost(username, slug):
    con = sqlite3.connect("donald.db")
    cur = con.cursor()

    sql = "SELECT * FROM posts WHERE username = \"%s\" AND slug = \"%s\"" % (
        username, slug)
    post = cur.execute(sql).fetchone()

    if post:
        post = transform.post(post)
        con.close()
        return post
    else:
        con.close()
        return False