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
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
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])
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
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
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
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