所有数据库名数据库密码等字符串都作为database_tools_2中的变量
This commit is contained in:
parent
7e5041eff7
commit
1905db3a3c
|
|
@ -23,6 +23,12 @@ BuildFullScheme = {
|
|||
}
|
||||
}
|
||||
|
||||
db_user = "tikuuser"
|
||||
db_pwd = "Kjmathds_2024"
|
||||
db_port = "13306"
|
||||
db_host = "wwylss.synology.me"
|
||||
db_database = "tiku"
|
||||
|
||||
def get_git_username():
|
||||
command = "git config --global user.name"
|
||||
stream = os.popen(command)
|
||||
|
|
@ -109,7 +115,7 @@ def findsru(id,alist): #在same_list中寻找与id相同的题号
|
|||
|
||||
|
||||
def findsameinDB(id): #在数据库中寻找与id相同的题号
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT SAME_ID FROM same WHERE ID = (%s);"
|
||||
val = (id,)
|
||||
|
|
@ -121,7 +127,7 @@ def findsameinDB(id): #在数据库中寻找与id相同的题号
|
|||
return sorted(list(set1 | set2))
|
||||
|
||||
def findrelatedinDB(id): #在数据库中寻找与id关联的题号
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT RELATED_ID FROM related WHERE ID = (%s);"
|
||||
val = (id,)
|
||||
|
|
@ -133,7 +139,7 @@ def findrelatedinDB(id): #在数据库中寻找与id关联的题号
|
|||
return sorted(list(set1 | set2))
|
||||
|
||||
def get_unit_tags(id):
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT tagname FROM tagcorresp WHERE ID = (%s);"
|
||||
val = (id,)
|
||||
|
|
@ -143,7 +149,7 @@ def get_unit_tags(id):
|
|||
return unittags
|
||||
|
||||
def get_problem_content(id):
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT content FROM problems WHERE ID = (%s);"
|
||||
val = (id,)
|
||||
|
|
@ -154,7 +160,7 @@ def get_problem_content(id):
|
|||
|
||||
|
||||
def generate_same_list():
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID,SAME_ID FROM same;")
|
||||
same_list = [(ret[0],ret[1]) for ret in mycursor.fetchall()]
|
||||
|
|
@ -162,7 +168,7 @@ def generate_same_list():
|
|||
return same_list.copy()
|
||||
|
||||
def generate_related_list():
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID,RELATED_ID FROM related;")
|
||||
related_list = [(ret[0],ret[1]) for ret in mycursor.fetchall()]
|
||||
|
|
@ -171,7 +177,7 @@ def generate_related_list():
|
|||
|
||||
def treat_dict(): #对整个题库字典中的内容部分进行预处理,删除无用字符
|
||||
treated_dict = {}
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID,content FROM problems;")
|
||||
p_dict = {id:content for id,content in mycursor.fetchall()}
|
||||
|
|
@ -345,7 +351,7 @@ def extractIDs(filePath): #提取.txt,.tex或.pdf文件中的题号, 返回含
|
|||
|
||||
|
||||
def spareIDs(): #返回空闲题号, 已更新为适合mariadb的版本
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID FROM problems;")
|
||||
idlist = [ret[0] for ret in mycursor.fetchall()]
|
||||
|
|
@ -360,7 +366,7 @@ def spareIDs(): #返回空闲题号, 已更新为适合mariadb的版本
|
|||
|
||||
|
||||
def NextSpareID(num): #返回adict中下一个空闲的题号
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID FROM problems;")
|
||||
idlist = [ret[0] for ret in mycursor.fetchall()]
|
||||
|
|
@ -371,7 +377,7 @@ def NextSpareID(num): #返回adict中下一个空闲的题号
|
|||
return num
|
||||
|
||||
def NextSpareIDBlock(num): #返回adict中下一个空闲的题号块
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID FROM problems;")
|
||||
idlist = [ret[0] for ret in mycursor.fetchall()]
|
||||
|
|
@ -482,7 +488,7 @@ def CreateNewProblem(id,content,origin,dict,editor): # 构建一道新题目的
|
|||
return NewProblem # 返回一道新题目的字典, 已赋新的ID, 内容, 来源和编辑者
|
||||
|
||||
def AddRelatedProblemToDB(id,content,oid,editor):
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
id = str(id).zfill(6)
|
||||
content = content.strip()
|
||||
|
|
@ -516,7 +522,7 @@ def AddRelatedProblemToDB(id,content,oid,editor):
|
|||
return id
|
||||
|
||||
def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexed): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目)
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
idlist = []
|
||||
id = int(startingid)
|
||||
|
|
@ -596,7 +602,7 @@ def CreateIDLinks(old_id_list,new_id_list): #建立已有id和新id之间的联
|
|||
|
||||
def CreateRelatedProblems(links): # 根据links关联生成待编辑的新题目字典, 等待编辑修改
|
||||
output = "\\begin{enumerate}\n"
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT content FROM problems WHERE ID = %s;"
|
||||
for id,rid in links:
|
||||
|
|
@ -1275,7 +1281,7 @@ def MatchConditioninMariaDB(condition_list):
|
|||
"related": ('related','ID','RELATED_ID'),
|
||||
"usages": ('usages','date','classname','diff')
|
||||
}
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID FROM problems WHERE NOT content REGEXP 'OBS';")
|
||||
match = set([u[0] for u in mycursor.fetchall()])
|
||||
|
|
@ -2448,7 +2454,7 @@ def generateAnswerList(string,anspreamble = "答案: \\textcolor{red}{"): #从La
|
|||
|
||||
def unUnitted(idexp): #返回adict中未赋单元的id列表
|
||||
idlist = generate_number_set(idexp)
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT ID FROM tagcorresp WHERE tagname REGEXP '第\\\\S*单元' or tagname = '暂无对应';")
|
||||
unittedids = set([ret[0] for ret in mycursor.fetchall()])
|
||||
|
|
@ -2736,7 +2742,7 @@ def RefineExclude(excludejson): #将excludejson的key变为6位题号
|
|||
def ChooseIDsByUsageInterval(startdate,enddate,interval,classregex): #返回根据条件选出的题号字典及对应小题, 需要留意的记录长度不一的题号, 以及所有使用过的题号
|
||||
validusages = []
|
||||
usedproblems = []
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT ID,date,classname,diff FROM usages;"
|
||||
mycursor.execute(sql)
|
||||
|
|
@ -2770,7 +2776,7 @@ def ChooseIDsByUsageInterval(startdate,enddate,interval,classregex): #返回根
|
|||
|
||||
|
||||
def getAllIDsExp(obsincluded = True): #获取题库中所有题目的id(含:,)字符串, 不含
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
if obsincluded:
|
||||
mycursor.execute("SELECT ID FROM problems;")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from database_tools_2 import *
|
|||
# prodict = load_dict("../题库0.3/Problems.json")
|
||||
# objdict = load_dict("../题库0.3/LessonObj.json")
|
||||
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
|
||||
|
||||
changedids = ImportMetadata(mydb,metadatafilepath)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.conditions = []
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT count(*) FROM problems WHERE NOT content REGEXP 'OBS';")
|
||||
self.lcdNumber_resCount.display(mycursor.fetchall()[0][0])
|
||||
|
|
@ -111,7 +111,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw)
|
||||
latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw)
|
||||
starttime = time.time()
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
bodystring = "\\begin{enumerate}\n\n"
|
||||
for id in generate_number_set(exp):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from database_tools_2 import *
|
||||
import tqdm
|
||||
same_list = generate_same_list()
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
for id,same_id in tqdm.tqdm(same_list):
|
||||
ShareSameUsagesinDB(id,same_id,mydb)
|
||||
mydb.commit()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
self.time = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
self.id = self.lineEdit_ID.text()
|
||||
self.dpi = self.lineEdit_dpi.text()
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
sql = "SELECT content FROM problems WHERE ID = %s;"
|
||||
val = (self.id.strip().zfill(6),)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
bodylist = []
|
||||
# problems_dict = configjson["标题与题号"]
|
||||
starttime = time.time()
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
for p,IDs in self.TitleID_list:
|
||||
currentbodystring = f"\\section{{{p}}}\n\\begin{{enumerate}}\n\n"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
self.lineEdit_filepath.setText(self.filepath)
|
||||
self.pushButton_exec.setEnabled(True)
|
||||
def exec(self):
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("SELECT bn_id FROM basic_knowledges;")
|
||||
bnids = [ret[0] for ret in mycursor.fetchall()]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from database_tools_2 import *
|
|||
colors = ["green","orange","blue"]
|
||||
templatepath = "./模板文件/讲义模板.txt"
|
||||
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
|
||||
mycursor.execute("SELECT ID,content FROM problems;")
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
if "校本材料.json" in files:
|
||||
jsondicts.append(load_dict(os.path.join(loc,"校本材料.json")))
|
||||
|
||||
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
mycursor = mydb.cursor()
|
||||
# raw_pro_dict = load_dict("../题库0.3/Problems.json")
|
||||
# obj_dict = load_dict("../题库0.3/LessonObj.json")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
self.pushButton_remarks.clicked.connect(self.showremarks)
|
||||
self.pushButton_exec.clicked.connect(self.exec)
|
||||
self.pushButton_tocommit.clicked.connect(self.tocommit)
|
||||
self.db = connect(hostname = "wwylss.synology.me", port = "13306", username = "tikuuser", pwd = "Kjmathds_2024", db = "tiku")
|
||||
self.db = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
|
||||
self.cursor = self.db.cursor()
|
||||
self.changedids = []
|
||||
def getID(self):
|
||||
|
|
|
|||
Reference in New Issue