MonetDB / pymonetdb

The Python API for MonetDB
https://www.monetdb.org/
Mozilla Public License 2.0
28 stars 20 forks source link

Value error in dates #107

Closed evangelos-dimitriadis closed 2 years ago

evangelos-dimitriadis commented 2 years ago

pymonetdb cannot handle all acceptable monetdb dates.

Replicate bug

SELECT DATE '2-01-01'

Or in VOC database execute:

SELECT min(cape_arrival) FROM voyages;

Result

ValueError: time data '2-01-01' does not match format '%Y-%m-%d'

joerivanruth commented 2 years ago

Thanks for noticing and reporting this.

As it turns out, MonetDB produces and accepts unpadded year numbers while the datetime.datetime.strptime() method we currently use to parse dates and times requires zero-padded years.

It gets worse than this, though. MonetDB also allows negative years and even year 0, whatever that may mean. Fortunately, Python's datetime.datetime type does not support nonpositive years anyway so we don't have to deal with that.

We will have to replace the uses of strptime with some custom code. Because strptime is written in Python and not C, this should not need to cause a performance degradation.