标签:cnAns word Day4 Scrum list 冲刺 cursor group6 sql
软件工程 | 网络工程1934 |
---|---|
这个作业要求在哪里 | 项目冲刺 |
这个作业的目标 | 站立式会议、燃尽图、签入记录、运行截图、每日总结 |
一、每日站立式会议
昨天完成的工作:
- 完成了注册和登录功能
- 研究如何从python传数组到js
工作中遇到的困难:
- 与前端对接数据结构
- 服务器收到请求之后没有应答
- 请求头跨域
- 如何将python的list直接导入sql表中
今天计划完成的工作:
- 开始开发查询单词
- 完成背单词功能的开发
- 完成复习单词功能的开发
- 将数据转至前端
二、项目燃尽图
三、成员代码
选择需要复习的单词
def getquestion(userid,number):#随机选择number个单词
db = pymysql.connect(host="localhost",user="root",password="28853379", database="group6")
cursor=db.cursor()
sql=" select wordid,english from group6.word where wordid in(select wordid from group6.user_"+str(userid)+" where status='0') order by rand() limit "+str(number)+";"
#print(sql)
cursor.execute(sql)
#db.commit()
results=cursor.fetchall()
return results
生成背单词选项
def getanswer(word):#获得四个中文选项,返回一个正确的和三个错误的
db = pymysql.connect(host="localhost",user="root",password="28853379", database="group6")
cursor=db.cursor()
sql=" select chinese from group6.word where wordid!="+"'"+word+"'"+" order by rand() limit 3;"
cursor.execute(sql)
#db.commit()
results=cursor.fetchall()
sql="select chinese from group6.word where english="+"'"+word+"'"+";"
print(sql)
cursor.execute(sql)
rightanswer=cursor.fetchall()
return rightanswer,results
前端访问数据的接口
# get_qu
def get_qu(body):
conc = pymysql.Connect(host='127.0.0.1', port=3306, user='root', password='28853379', database='group6', charset='utf8')
cur = conc.cursor()
try:
sql = "SELECT plan FROM user WHERE id = "+str(body[0])+";"
cur.execute(sql)
plan = cur.fetchall()[0][0]
sql = "select wordid,english from group6.word where wordid in(select wordid from group6.user_" + str(body[0]) + " where status='0') order by rand() limit "+str(plan)+";"
cur.execute(sql)
result = cur.fetchall()
data_list = []
for each in result:
sql = " select chinese from group6.word where wordid!=" + "'" + str(each[1]) + "'" + " order by rand() limit 3;"
cnAns = cur.fetchall()
cnAns_list = [cnAns[0][0], cnAns[1][0], cnAns[2][0], each[2]]
random.shuffle(cnAns_list)
data_list.append({
"cn": each[2],
"en": each[1],
"cnAns": [cnAns_list[0], cnAns_list[1], cnAns_list[2], cnAns_list[3]]
})
except Exception as e:
print('操作失败:', e)
data_list = []
data_list.append({
"ret": 1,
"msg": str(e)
})
# 回滚数据
conc.rollback()
finally:
# 关闭游标对象
cur.close()
# 关闭连接
conc.close()
# 状态信息
status = "200 OK"
# 响应头信息
response_header = [
("Server", "PWS/1.1"),
# 指定编码格式,因为没有模板文件,可以通过响应头指定编码格式
("Content-Type", "text/html;charset=utf-8")
]
return status, response_header, str(data_list)
四、程序运行截图
五、每日总结
啊啦,暂时没有哦
标签:cnAns,word,Day4,Scrum,list,冲刺,cursor,group6,sql 来源: https://www.cnblogs.com/juseice/p/15614141.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。