Mysql想插入数据有点问题
代码是:
sample_cmd = 'SELECT s.InfoId, s.UserName, s.Disease , s.Defined5, r.InfoId\
InfoId1,r.ReportDate FROM dbo.J_SampleRegister s inner \
join (SELECT distinct InfoId,ReportDate,Id FROM dbo.J_Report)\
r on s.InfoId=r.InfoId WHERE s.Disease = "药物分析" and\
r.ReportDate >= \'%s\' and r.ReportDate <= \'%s\' ORDER \
BY r.Id;' % (s_time, e_time)
报错信息是:
(207, b"Invalid column name '\xe6\x8a\x97\xe7\x99\xab\xe7\x97\xab\xe8\x8d\xaf\xe7\x89\xa9\xe5\x88\x86\xe6\x9e\x90'.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n")
百度了半天,也没收获。后来把那个药物分析的双引号改成了单引号
sample_cmd = 'SELECT s.InfoId, s.UserName, s.Disease , s.Defined5, r.InfoId\
InfoId1,r.ReportDate FROM dbo.J_SampleRegister s inner \
join (SELECT distinct InfoId,ReportDate,Id FROM dbo.J_Report)\
r on s.InfoId=r.InfoId WHERE s.Disease = \'药物分析\' and\
r.ReportDate >= \'%s\' and r.ReportDate <= \'%s\' ORDER \
BY r.Id;' % (s_time, e_time)
就没问题了。怪自己太菜。。。