c.execute("SELECT * FROM Student WHERE Forename =:forename AND Surname =:surname AND YearGroup =:yeargroup AND FormNumber =:formnumber BETWEEN :startdate AND :enddate", {"forename": forename, "surname": surname, "yeargroup": yeargroup, "formnumber": formnumber, "startdate": startdate, "enddate": enddate})
studentRequest = c.fetchall()
records = studentRequest
#write to file
f = open('Student Report', 'w')
f.write(name)
f.write(' Form Number: ' + (yeargroup +'/'+ formnumber))
f.write(str(records))
f.close()
这是我的代码,但似乎没有将数据库中的数据写入文件。名称,论坛编号等已被写入。
有人可以帮忙吗?
最佳答案
您的输出中是否包含“ []”?听起来您的查询找不到任何匹配项。
如果不是这样,请准备一个显示问题的complete, runnable示例。