def instance(): if not hasattr(DbManager, "_instance"): DbManager._instance = DbManager() DbManager._db_conn = MysqlConnect() DbManager._daos.update({ 'media': MediaDao(DbManager._db_conn), 'video': VideoDao(DbManager._db_conn), 'play_url': PlayUrlDao(DbManager._db_conn), 'site': SiteDao(DbManager._db_conn), 'channel': ChannelDao(DbManager._db_conn), 'os': OsDao(DbManager._db_conn), 'sync': SyncDao(DbManager._db_conn), 'untrack': UntrackDao(DbManager._db_conn), 'review': ReviewDao(DbManager._db_conn), 'poster_filter': PosterFilterDao(DbManager._db_conn), }) return DbManager._instance
def instance(): if not hasattr(DbManager, "_instance"): DbManager._instance = DbManager() DbManager._db_conn = MysqlConnect() DbManager._daos.update({ 'episode': EpisodeDao(DbManager._db_conn), 'user': UserDao(DbManager._db_conn), 'keyword': KeywordDao(DbManager._db_conn), 'keyword_episode': KeywordEpisodeDao(DbManager._db_conn), 'subject': SubjectDao(DbManager._db_conn), 'subject_episode': SubjectEpisodeDao(DbManager._db_conn), 'page_episode': PageEpisodeDao(DbManager._db_conn), 'ordered': OrderedDao(DbManager._db_conn), 'page': PageDao(DbManager._db_conn), 'cat_list': CatListDao(DbManager._db_conn), 'cat_episode': CatListEpisodeDao(DbManager._db_conn), 'cat_exclude': CatExcludeDao(DbManager._db_conn), 'channel_exclude': ChannelExcludeDao(DbManager._db_conn), 'category': CategoryDao(DbManager._db_conn), 'tag': TagDao(DbManager._db_conn), }) return DbManager._instance
def add_keyword_episode(self, value_dict): try: keys = value_dict.keys() values = value_dict.values() sql = "REPLACE INTO %s (%s) VALUES (%s)" % ( self._tb_name, ",".join(keys), ",".join(['%s'] * len(keys))) para = values self._db_conn.execute_sql(sql, para) except Exception, e: log.msg(traceback.format_exc(), level=log.ERROR) if __name__ == "__main__": try: import json log.start(loglevel='INFO') db_conn = MysqlConnect() kwep_dao = KeywordEpisodeDao(db_conn) kwep_dao.add_keyword_episode({'kw_id': '20', 'show_id': 'xx33ff'}) db_conn.commit() db_conn.commit() except Exception,e: log.msg(traceback.format_exc(), level=log.ERROR)
try: sql = "select count(*) from poster_filter where md5=%s" para = (md5, ) res = self._db_conn.db_fetchall(sql, para) if res and res[0][0] > 0: return True else: return False except Exception, e: logging.log(logging.ERROR, traceback.format_exc()) def get_poster_filter_md5(self): try: sql = "select md5 from poster_filter" res = self._db_conn.db_fetchall(sql) if res: return [r[0] for r in res] else: return [] except Exception, e: logging.log(logging.ERROR, traceback.format_exc()) if __name__ == "__main__": db_conn = MysqlConnect() dao = PosterFilterDao(db_conn) #res = dao.has_poster_filter_md5('969fb1ad59ae31bd36c55b25a5d9100a') res = dao.get_poster_filter_md5() print res