from datetime import datetime

from sqlalchemy.schema import Column
from sqlalchemy.types import DateTime, Integer

from sqlalchemy.ext.declarative import declarative_base, declared_attr


Base = declarative_base()


class BaseMixin:

    id = Column(Integer, primary_key=True)

    @declared_attr
    def __tablename__(cls):
        return cls.__name__.lower()


class TimestampMixin:

    created_at = Column(DateTime, nullable=False, default=datetime.now)
    updated_at = Column(DateTime, onupdate=datetime.now)

import datetime

from sqlalchemy.schema import Column
from sqlalchemy.types import DateTime, Integer

from sqlalchemy.ext.declarative import declarative_base, declared_attr


Base = declarative_base()


class BaseMixin:

    id = Column(Integer, primary_key=True)

    @declared_attr
    def __tablename__(cls):
        return cls.__name__.lower()


class TimestampMixin:

    created_at = Column(
        DateTime, nullable=False, default=datetime.datetime.now)
    updated_at = Column(DateTime)

--- 
+++ 
@@ -1,4 +1,4 @@
-import datetime
+from datetime import datetime
 
 from sqlalchemy.schema import Column
 from sqlalchemy.types import DateTime, Integer
@@ -20,6 +20,5 @@
 
 class TimestampMixin:
 
-    created_at = Column(
-        DateTime, nullable=False, default=datetime.datetime.now)
-    updated_at = Column(DateTime)
+    created_at = Column(DateTime, nullable=False, default=datetime.now)
+    updated_at = Column(DateTime, onupdate=datetime.now)
Update updated time on update

I.e., added onupdate=datetime.now to TimestampMixin.updated_at so that it will
be automatically updated whenever a record is edited.
