sqlalchemy function for default value for column

Solutions on MaxInterview for sqlalchemy function for default value for column by the best coders in the world

showing results for - "sqlalchemy function for default value for column"
Debora
26 Aug 2019
1def mydefault(context):
2    return context.get_current_parameters()['counter'] + 12
3
4t = Table('mytable', meta,
5    Column('counter', Integer),
6    Column('counter_plus_twelve', Integer, default=mydefault, onupdate=mydefault)
7)
Leni
05 Feb 2017
1# a function which counts upwards
2i = 0
3def mydefault():
4    global i
5    i += 1
6    return i
7
8t = Table("mytable", meta,
9    Column('id', Integer, primary_key=True, default=mydefault),
10)