Answers for "sqlalchemy function for default value for column"

0

sqlalchemy function for default value for column

def mydefault(context):
    return context.get_current_parameters()['counter'] + 12

t = Table('mytable', meta,
    Column('counter', Integer),
    Column('counter_plus_twelve', Integer, default=mydefault, onupdate=mydefault)
)
Posted by: Guest on February-11-2021
0

sqlalchemy function for default value for column

# a function which counts upwards
i = 0
def mydefault():
    global i
    i += 1
    return i

t = Table("mytable", meta,
    Column('id', Integer, primary_key=True, default=mydefault),
)
Posted by: Guest on February-11-2021

Code answers related to "sqlalchemy function for default value for column"

Python Answers by Framework

Browse Popular Code Answers by Language