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