from libs.db_mysql import DbMysql class MysqlDyLive(DbMysql): table = 'douyin_live' # 获取直播数据 def get_live_info(self, room_id): sql = 'SELECT id,room_id,status FROM ' + self.table + ' WHERE `room_id`=%s LIMIT 1' try: # 执行SQL self.cursor.execute(sql, [room_id]) return self.cursor.fetchone() finally: self.db.commit() # 提交 self.cursor.close() # 关闭cursor self.db.close() # 关闭db连接