Setting a default value in sqlalchemy

The documentation gives the following possibilities for default:

A scalar, Python callable, or ClauseElement representing the default
value for this column, which will be invoked upon insert if this
column is otherwise not specified in the VALUES clause of the insert.

You may look into using a simple function, or you may just be able to use a select() object.

In your case, maybe something along the lines of:

from sqlalchemy.sql import select, func
...
Column('version', Integer, default=select([func.max(1,
    func.max(version_table.c.old_versions))]))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)