利用python筛选出当天的数据

wulabaha 发布于 2018/11/21 14:19
阅读 477
收藏 0

软件工程师和算法工程师速来!正在直播:如何使用英特尔oneAPI工具实现PyTorch 优化>>>

 


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 Server\n')
##############

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 Server\n")

####
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 Server\n")
########
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 Server\n")
#############

出错信息: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 Server\n")

加载中
0
w
wulabaha

 没有加入列


sql = 'select * from RSS where DateDiff(dd,FDate,getdate())=0'

 

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部
返回顶部
顶部