Ejemplo n.º 1
0
def getVideos(tags=None, createdBy=None, count=None):
    with Cursor() as cursor:
        #what to project
        project = " COUNT(*) " if count else " * "
        query = "SELECT %s FROM VIDEOS " % project

        #where clauses
        tagsq = None if not tags else "tags = '%s' " % (tags, )
        createdByq = None if not createdBy else "createdBy = '%s' " % (createdBy, )

        query += utils.joinWheres([tagsq, createdByq])
        cursor.execute(query)
        return fetchall(cursor)
Ejemplo n.º 2
0
 def test_joinWheres(self):
     wheres = ['a = 1234 ', None, 'b = 456 ']
     result = utils.joinWheres(wheres)
     self.assertEqual(result, 'WHERE a = 1234 AND b = 456 ')
Ejemplo n.º 3
0
 def test_joinWheres(self):
     wheres = ['a = 1234 ' , None, 'b = 456 ']
     result =  utils.joinWheres(wheres)
     self.assertEqual(result , 'WHERE a = 1234 AND b = 456 ')