Record the first time created, default
Falsk the following two fields
CREATE_TIME1 = db. Column (db. DateTime, default== db. Column (db. DateTime, Default=datetime.now ())
The difference between the two:
The first insert is expected, the data insertion time, each data inserted can be automatically based on the current time generation
The second is a fixed time, the program deployment time, all the data is this fixed time
In fact, the default value is not reflected in the MySQL database, which is sqlalchemy when inserting data.
If you want to have default values in the generated table, use Server_default
Name = db. Column (db. String (server_default=' hh')
Because the MySQL datetime type data does not support functions, it is not able to specify the default value bit current time
Record the time of each modification, OnUpdate
Update_time = db. Column (db. DateTime, Default=datetime.now,onupdate=datetime.now)
DateTime creation time, modification time, default,server_default,onupdate in Flask-sqlalchemy