I'm using Peewee to access a SQLite DB. How can I save a timestamp in the following format?
'%Y-%m-%d %H:%M:%S' # year-month-day hour-minute-second
(basically: just crop out the microseconds which are present by default)
EDIT: I was able to make this work, using the following in the class definition:
created = DateTimeField(default=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S))
However, I'm still intersted to know if there's a "built in" way of doing this with Peewee, using the 'formats' parameter.
Aucun commentaire:
Enregistrer un commentaire