[Flask] Getting a timestamp column wrong for an existing database table

Skip Montanaro skip.montanaro at gmail.com
Tue May 7 14:48:25 EDT 2019


I'm trying to model an existing SQL Server table. It has a stamp
column of type datetime. I tried declaring it like so:

class Summary(DB.Model):
    ...
    stamp = DB.Column(DB.TIMESTAMP)
    ...

When I start my Flask server, it complains:

Attribute 'stamp' on class <class 'app.models.Summary'> appears to be
a non-schema 'sqlalchemy.sql.column()' object; this won't be part of
the declarative mapping

I've tried the following, all to no avail:

* DB.Column(DB.DATETIME)
* Changed the column in the database from datetime to datetime2
* DB.Column(SMALLDATETIME), where that comes from sqlalchemy.dialects.mssql.

How do I deal with this? I'm currently unable to use stamp as a query
constraint (at least I think so).

Skip Montanaro


More information about the Flask mailing list