schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

sqlite loses timezone awareness #29

Closed DanCardin closed 5 years ago

DanCardin commented 5 years ago

https://stackoverflow.com/questions/36730671/how-to-store-timezone-aware-timestamps-in-sqlite3-with-python

e.g. if you save a utc timezone'd datetime, when it comes back out, it will come out as a datetime object without a timezone. which means you get errors if you try to compare it to a timezone'd datetime.

Since you can't determine tz once its in the db anyways, i just request we use the adaptor from the above example, not to localize the timezone, but to add a tzinfo=timezone.utc to the vanilla datetime object which is returned