You can decide to shun these principles but then you have to deal with the consequences, such as wondering if SQLite can be coerced into executing some Python code (or Perl or Haskell or Scheme or, $deity forbids, Visual Basic). DB systems typically provide convenient date/time related functions that can be used in queries. DB systems all have a built-in date/time type (where date/time is typically represented internally as seconds from the epoch (, 00:00 UTC)), and a good design uses these, while application-level functions converts between the external representation(*) and the DB ones where necessary. A date is a date (some instant in time) whether it's Chinese or French or Sudanese. But for some reason I got an sqlite3.operationalError from running it.Īm I in the wrong path to achieve my goal? Thank you very much. ![]() This comparison is legal in the pure Python context because both sides are a ChineseDate instance. SELECT * FROM myTable WHERE MyDate > MyModule.ChineseDate("兔年八月十五") Now I want to select all the records with their MyDate column later than a certain 兔年八月十五, so I built this query: When inserted into that column, the python ChineseDate object will be automatically adapted into a complex string, containing the first occuring date and the interval, etc. ![]() I used detect_types=sqlite3.PARSE_DECLTYPES to tell the connection object to store this ChineseDate type directly into one column in my schema. I coded a module that has a ChineseDate class, which automatically parse Chinese dates characters into a python-dateutil object(which actually is a datetime.datetime object as well). Yes, here is what I'm doing and what I wanted to achieve. SQL is simple and doesn't know the concept of objects.Ĭould you elaborate what exactly you want to achieve? What do you mean by recurring and what that has to do with dates in db?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |