利用python筛选出当天的数据
import pymssql
import pandas as pd
###连接sql sever并读取数据到dataframe
conn = pymssql.connect('fghdfhgn', 'sa', 'hgjfhg', '57574')
cursor = conn.cursor()
#########读取当天的数据###
sql = 'select * from RSS where FDate=2018-11-21'
test = pd.read_sql(sql, conn)
DatabaseError: Execution failed on sql 'select * from RSS where FDate=2018-11-21': (206, b'Operand type clash: date is incompatible with intDB-Lib error message 20018, severity 16:nGeneral SQL Server error: Check messages from the SQL Servern')
##############
sql = '''select * from RSS where FDate(checktime,'%Y-%m-%d')=2018-11-21'''
test = pd.read_sql(sql, conn)
DatabaseError: Execution failed on sql 'select * from RSS where FDate(checktime,'%Y-%m-%d')=2018-11-21': (195, b"'FDate' is not a recognized built-in function name.DB-Lib error message 20018, severity 15:nGeneral SQL Server error: Check messages from the SQL Servern")
####
sql = 'select * from RSS where to_days(FDate) = to_days(now())'
test = pd.read_sql(sql, conn)
DatabaseError: Execution failed on sql 'select * from RSS where to_days(FDate) = to_days(now())': (195, b"'to_days' is not a recognized built-in function name.DB-Lib error message 20018, severity 15:nGeneral SQL Server error: Check messages from the SQL Servern")
########
sql = 'SELECT * FROM RSS where DATEDIFF(day,inputdate,GETDATE())=0'
test = pd.read_sql(sql, conn)
DatabaseError: Execution failed on sql 'SELECT * FROM RSS where DATEDIFF(day,inputdate,GETDATE())=0': (207, b"Invalid column name 'inputdate'.DB-Lib error message 20018, severity 16:nGeneral SQL Server error: Check messages from the SQL Servern")
#############
出错信息:DatabaseError: Execution failed on sql 'select * from RSS where datediff(day,ordTime,getdate()-1)=0 ': (207, b"Invalid column name 'ordTime'.DB-Lib error message 20018, severity 16:nGeneral SQL Server error: Check messages from the SQL Servern")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有加入列