1234567891011121314151617181920212223242526272829303132 |
- from libs.db_mysql import DbMysql
- class MysqlUserLiving(DbMysql):
- def __init__(self):
- super().__init__()
- 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.cursor.execute(sql)
- return self.cursor.fetchone()
- finally:
- # 提交到数据库执行
- self.db.commit()
- # 最终关闭数据库连接
- self.cursor.close()
- self.db.close()
-
- def get_user_info(self, uid):
- sql = 'SELECT `sec_uid` FROM `douyin_users` WHERE `uid`=' + uid
- try:
- # 查询数据
- self.cursor.execute(sql)
- return self.cursor.fetchone()
- finally:
- # 提交到数据库执行
- self.db.commit()
- # 最终关闭数据库连接
- self.cursor.close()
- self.db.close()
|