# cannot compare timzeone aware and timezone naiveÄbDatetimeNoTz = arrowDt # False, or TypeError on python versions before 3.3 # MySQL example! where MySQL doesn't support timezones with its DATETIME type! Also note that you cannot compare datetime.datetime objects where one is timezone aware and another is timezone naive. The solution is to convert your datetime.datetime object to UTC (so everything in your database is UTC since it can't specify timezone) then either insert it into the database (where the timezone is removed anyway) or remove it yourself. Timezone when you give it a datetime.datetime object to insert into the database. So using ORM's like sqlalchemy will simply remove the Why would you do this? One example is that mysql does not support timezones with its DATETIME type. TmpDatetime = tmpDatetime.replace(tzinfo=None) If you are using a library like arrow, then you can remove timezone by simply converting an arrow object to to a datetime object, then doing the same thing as the example above. How do you convert UTC to time in python?.How do I remove the timezone from a date in python?.How do I remove the timezone from a datetime column in Python?.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |