Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Datetime format in sqlite

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Recently, when I looked at Flask, there was a requirement to use Flask to make a custom api call to a project. I saw that there was an error when running the code here in the database:

Check the date field in table, and it is in date format, that's right:

Field information of table:

So I looked it up on the Internet and said that there is a difference between Python's datetime and sqlite's datetime. The storage format of datetime in sqlite is: yyyy-mm-dd hh:mm:ss.

The format of datetime I inserted into table was yyyy/mm/dd hh:mm:ss, so I inserted a few more pieces of data in the format of sqlite, yyyy-mm-dd hh:mm:ss. As you can see in the following figure, there are two types of data formats.

Re-visit api, this time to visit the data with the correct date format, that's right.

In fact, a better solution is to insert data, if not the default date format of sqlite, plus a date format conversion, to solve this problem. You can try it sometime. I hope this blog can help friends who encounter the same problems.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 263

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report