weverse-script/dao.py

36 lines
987 B
Python
Raw Normal View History

2025-02-10 05:49:57 +00:00
import db
# 数据库连接
try:
db_conn = db.DatabaseConnection()
except Exception as e:
print("数据库连接失败!")
finally:
pass
# 根据num查询演出
def get_apply(num):
query = "SELECT * FROM perform WHERE num = %s limit 1"
result = db_conn.execute_query(query, num)
return result
# 根据演出id查询参与用户
def get_apply_user(pid):
query = "SELECT a.id, u.weverse_email,u.country_code, u.phone_num, u.weverse_password, u.birthday, u.wechat_num FROM apply a left join sys_user u on a.user_id=u.user_id WHERE a.perform_id = %s and a.status = '1' and a.token is null"
result = db_conn.execute_query(query, pid)
return result
# 根据申请id更新token和状态
def update_token(aid, token):
query = "UPDATE apply SET token = %s , status = '2' WHERE id = %s"
db_conn.execute_commit(query, (token, aid))
# apply = get_apply(1)
# if apply:
# user = get_apply_user(apply[0][0])
# print(user)