12345678910111213141516171819 |
- from libs.db_mysql import DbMysql
- class MysqlUserLiving(DbMysql):
- def __init__(self):
- super().__test__()
- def get_living_info(self):
- sql = 'SELECT `room_id`,l.`uid`,u.`sec_uid` FROM douyin_live as l left join douyin_users as u on l.`uid`=u.`uid` WHERE `finish_time`=0 and `has_commerce_goods`=1 order by l.`sell_count_sum` desc LIMIT 1'
- try:
- # 查询数据
- self.test.execute(sql)
- return self.test.fetchone()
- finally:
- # 提交到数据库执行
- self.db.commit()
- # 最终关闭数据库连接
- self.test.close()
- self.db.close()
|