mirror of
https://github.com/Kakune55/PyGetGPT.git
synced 2025-06-29 00:08:04 +08:00
添加了创建key工具和删除空key工具
This commit is contained in:
parent
1c36a170b0
commit
02f1140434
26
createKey.py
Normal file
26
createKey.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import uuid , pymysql
|
||||||
|
|
||||||
|
surplus = int(input("usrplus:"))
|
||||||
|
number = int(input("number:"))
|
||||||
|
#打开数据库连接
|
||||||
|
db = pymysql.connect(host='www.kakuweb.top',
|
||||||
|
port=33306,
|
||||||
|
user='root',
|
||||||
|
password='KAku3.14159..',
|
||||||
|
database='AIapi')
|
||||||
|
# 使用 cursor() 方法创建一个游标对象 cursor
|
||||||
|
cursor = db.cursor()
|
||||||
|
for i in range(0,number):
|
||||||
|
tempuuid = uuid.uuid4()
|
||||||
|
print(tempuuid)
|
||||||
|
# 使用 execute() 方法执行 SQL 查询
|
||||||
|
cursor.execute(f"INSERT INTO usersurplus (userkey, surplus) VALUES ('{tempuuid}', {surplus});")
|
||||||
|
|
||||||
|
# 提交事务
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
# 关闭连接
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
print("生成完成")
|
||||||
|
input()
|
19
deleteEmptyKey.py
Normal file
19
deleteEmptyKey.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pymysql
|
||||||
|
#打开数据库连接
|
||||||
|
db = pymysql.connect(host='www.kakuweb.top',
|
||||||
|
port=33306,
|
||||||
|
user='root',
|
||||||
|
password='KAku3.14159..',
|
||||||
|
database='AIapi')
|
||||||
|
# 使用 cursor() 方法创建一个游标对象 cursor
|
||||||
|
cursor = db.cursor()
|
||||||
|
|
||||||
|
cursor.execute("DELETE FROM usersurplus WHERE surplus < 1;")
|
||||||
|
|
||||||
|
# 提交事务
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
# 关闭连接
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
print("已完成删除")
|
@ -48,6 +48,10 @@ def userSurplus(userkey):
|
|||||||
cursor.execute(f"SELECT surplus FROM usersurplus WHERE userkey = '{userkey}';")
|
cursor.execute(f"SELECT surplus FROM usersurplus WHERE userkey = '{userkey}';")
|
||||||
# 使用 fetchone() 方法获取单条数据.
|
# 使用 fetchone() 方法获取单条数据.
|
||||||
data = cursor.fetchone()
|
data = cursor.fetchone()
|
||||||
|
|
||||||
|
# 关闭连接
|
||||||
|
db.close()
|
||||||
|
|
||||||
if data != None:
|
if data != None:
|
||||||
return data[0]
|
return data[0]
|
||||||
return -99999
|
return -99999
|
||||||
|
Loading…
x
Reference in New Issue
Block a user