예제 #1
0
    def selectAppByName(self, name):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM apps WHERE name="{name}"'''.format(name=name)
        #print(sql)
        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchone()

        self.mSQLConn.close()

        if (res == None):
            return

        app = App()
        app.initByTuple(res)

        return app
예제 #2
0
    def selectAppById(self, id):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM apps WHERE id={id}'''.format(id=id)
        #print(sql)
        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchone()

        self.mSQLConn.close()

        if (res == None):
            return

        app = App()
        app.initByTuple(res)

        return app
예제 #3
0
    def selectAllApps(self, where=""):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM apps {where}'''.format(where=where)
        #print(sql)
        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchall()

        self.mSQLConn.close()

        if (res == None):
            return

        apps = []

        for i in res:
            app = App()
            app.initByTuple(i)
            apps.append(app)

        return apps
예제 #4
0
    def selectAppsByStar(self):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM apps WHERE star>0 ORDER BY star'''
        #print(sql)
        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchall()

        self.mSQLConn.close()

        if (res == None):
            return

        apps = []

        for i in res:
            app = App()
            app.initByTuple(i)
            apps.append(app)

        return apps
예제 #5
0
    def selectAppsByCategoryOrderByNewestPrice(self, category, order=""):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM (SELECT apps.*,price.price FROM apps,price WHERE apps.appid=price.appid AND price.createtime IN (SELECT MAX(price.createtime) FROM price GROUP BY price.appid)) WHERE applicationcategory="{category}" {order}'''.format(
            category=category, order=order)

        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchall()

        self.mSQLConn.close()

        if (res == None):
            return

        apps = []

        for i in res:
            app = App()
            app.initByTuple(i)
            apps.append(app)

        return apps
예제 #6
0
    def selectAppsByCategory(self, category, order=""):
        self.mSQLConn.connect()

        sql = '''SELECT * FROM apps WHERE applicationCategory="{category}" {order}'''.format(
            category=category, order=order)
        #print(sql)
        self.mSQLConn.execute(sql)

        res = self.mSQLConn.fetchall()

        self.mSQLConn.close()

        if (res == None):
            return

        apps = []

        for i in res:
            app = App()
            app.initByTuple(i)
            apps.append(app)

        return apps