初次提交
This commit is contained in:
20
backend/cleanup_test_user.py
Normal file
20
backend/cleanup_test_user.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from app.core.database import SessionLocal
|
||||
from app.models.user import User
|
||||
|
||||
def cleanup_test_user():
|
||||
"""清理测试用户"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# 删除测试用户
|
||||
test_user = db.query(User).filter(User.username == "peng").first()
|
||||
if test_user:
|
||||
db.delete(test_user)
|
||||
db.commit()
|
||||
print("已删除测试用户 'peng'")
|
||||
else:
|
||||
print("未找到测试用户 'peng'")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
cleanup_test_user()
|
||||
Reference in New Issue
Block a user