You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
#!/usr/bin/env python3
|
|
"""
|
|
一键将 kimi_tokens.db 中所有记录的 status 设置为 active
|
|
"""
|
|
|
|
import sqlite3
|
|
import os
|
|
import sys
|
|
|
|
|
|
def main():
|
|
# 获取脚本所在目录
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
db_path = os.path.join(script_dir, '../kimi_tokens.db')
|
|
|
|
# 检查数据库文件是否存在
|
|
if not os.path.exists(db_path):
|
|
print(f"错误:数据库文件不存在 - {db_path}")
|
|
sys.exit(1)
|
|
|
|
try:
|
|
# 连接数据库
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# 更新所有记录的 status 为 active
|
|
cursor.execute("UPDATE tokens SET status = 'active'")
|
|
updated_rows = cursor.rowcount
|
|
|
|
# 提交更改
|
|
conn.commit()
|
|
|
|
print(f"成功更新 {updated_rows} 条记录的 status 为 'active'")
|
|
|
|
except sqlite3.Error as e:
|
|
print(f"数据库错误:{e}")
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"未知错误:{e}")
|
|
sys.exit(1)
|
|
finally:
|
|
if 'conn' in locals():
|
|
conn.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|