使用ODBC从HFSQL数据库读取日期时的ValueError
在一些挣扎中,我使用ODBC连接到HFSQL服务器。我已经尝试了pypyodbc和pyodbc。 我的目标是在数据中获得一些见解(并可视化某些方面)。
对于一些计划可视化,我需要读取一些数据,这些数据适用于大多数表和列。但是,当我尝试读取包含日期的列时,我会得到一个值:
invalid literal for int() with base 10: ''
所有行都包含一个有效的日期。
这是当前产生上述错误的代码:
deadlines = db.cursor()
query = ("SELECT DeliveryDate FROM Orders WHERE Finished = 0")
deadlines.execute(query)
print(deadlines.fetchone()) #<- this goes wrong
db是数据库(与其他查询一起使用)
print(deadlines.description)
给出:[' )
我还尝试了:(
pandas.read_sql(query,db,parse_dates={'DeliveryDate': {"dayfirst": True}})
日期是27-6-2022) 不幸的是,这给出了相同的错误。
任何帮助将不胜感激, 干杯,
With some struggles I connected to a hfsql server using ODBC. I've tried both pypyodbc and pyodbc.
My goal is to get some insights in the data (and visualize some aspects).
For some planning visualization I need to read out some of the data, which works fine for most tables and columns. However, when I try to read out a column containing dates i get a ValueError:
invalid literal for int() with base 10: ''
All rows contain a valid date.
This is the code that currently produces the error above:
deadlines = db.cursor()
query = ("SELECT DeliveryDate FROM Orders WHERE Finished = 0")
deadlines.execute(query)
print(deadlines.fetchone()) #<- this goes wrong
db is the database (it works with other queries)
print(deadlines.description)
gives: [('deliverydate', <class 'datetime.date'>, 11, 9, 9, 0, True)]
I also tried:
pandas.read_sql(query,db,parse_dates={'DeliveryDate': {"dayfirst": True}})
(dates are e.g. 27-6-2022)
Which unfortunately gives the same error.
Any help would be appreciated,
cheers,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(如该问题的评论中所建议的)解决了问题。
(as suggested in a comment to the question) solved the issue.