sqlalchemy无法从sqlite3(0000-00-00)读取空日期:ValueError:year超出范围

时间:2016-10-18 21:20:29

标签: python sqlalchemy

当我尝试使用0000-00-00 00:00:00查询包含sqlachemy等日期的数据库时,我得到ValueError: year is out of range

这是db dump:

enter image description here

这是堆栈跟踪:

File "/home/rob/.virtualenvs/calif/lib/python3.5/site-packages/sqlalchemy/engine/result.py" in items
  163.         return [(key, self[key]) for key in self.keys()]

File "/home/rob/.virtualenvs/calif/lib/python3.5/site-packages/sqlalchemy/engine/result.py" in <listcomp>
  163.         return [(key, self[key]) for key in self.keys()]

File "/home/rob/.virtualenvs/calif/lib/python3.5/site-packages/sqlalchemy/engine/result.py" in __getitem__
  90.                 return processor(self._row[index])

File "/home/rob/.virtualenvs/calif/lib/python3.5/site-packages/sqlalchemy/processors.py" in process
  48.                 return type_(*list(map(int, m.groups(0))))

Exception Type: ValueError at /
Exception Value: year is out of range

这是正常的吗? sqlalchemy可以读这样的日期吗?这是python的限制吗?有没有解决方法来保持日期不变(不转换为无)?

1 个答案:

答案 0 :(得分:0)

通过IRC上的inklesspen获得答案:Python datetime representation has minimum year and it's 1