Sqlalchemy: add date to column

Viewed 328

I want to add a date to a column in Sqlalchemy, and when I change the value of the instance of the column the date also will change.

As an example this is a model:

class Servers(db.Model):
 id = db.Column(db.Integer, primary_key=True)
 server_name = db.Column(db.String(120), unique=True)
 server_ip = db.Column(db.String(12), nullable=False, unique=True)
 server_status = db.Column(db.String(12))
 date_created = db.Column(db.DateTime, default=datetime.utcnow)

I want to add to server_status a date and to run a function every x seconds that check the server status and change it when his status changes and when server_status changes I want his date also change so I could show the server status and the exact time it changed

0 Answers
Related