在使用 flask_sqlalchemy 中向数据库添加日期
default=datetime.datetime.now这样是能连时间一起获取的,但是我想要的效果的单单获取日期,不带时间,我试过
datetime.date.day结果报sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '<attribute 'day' of 'datetime.date' objects>' for column 'join_time' at row 1") [SQL: u'INSERT INTO music_user (email, username, _password, avata r, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: ('[email protected]', 'char1998', 'pbkdf2:sha1:1000$5CkzkpB1$38c28dfaa9556649857ae6442b8cbe2e29e8890d', None, <attribute 'day' of 'datetime.date' objects>, 3)]
datetime.datetime.day报了sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '<attribute 'day' of 'datetime.date' objects>' for column 'join_time' at row 1") [SQL: u'INSERT INTO music_user (email, username, _password, avata r, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: ('[email protected]', 'char1998', 'pbkdf2:sha1:1000$SNKS5Gsm$ba00dd797aa0ac25049bef2dc2042790915cb8be', None, <attribute 'day' of 'datetime.date' objects>, 3)]
datetime.datesqlalchemy.exc.StatementError: (exceptions.TypeError) Required argument 'year' (pos 1) not found [SQL: u'INSERT INTO music_user (email, username, _password, avatar, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: [{'username': 'char1998' , '_password': 'pbkdf2:sha1:1000$kCRVx1le$1a8afcf0e9640b0fe3181929cc02a5e0d07e0c0d', 'email': '[email protected]', 'avatar': None}]]
datetime.datetime.date()TypeError: descriptor 'date' of 'datetime.datetime' object needs an argument
datetime.datetime.dateAttributeError: 'method_descriptor' object has no attribute '__module__'