I want to set the default value of my SQLAlchemy postgres JSON column to an empty dictionary.
from sqlalchemy.dialects.postgresql import JSON
info = Column(JSON, default='{}')
info = Column(JSON, default={})
Neither of these work.
I want to set the default value of my SQLAlchemy postgres JSON column to an empty dictionary.
Neither of these work. |
|||
Using default=lambda: {} works. Credit goes to univerio in the comments. |
|||
|
asked |
3 months ago |
viewed |
68 times |
active |
Technology | Life / Arts | Culture / Recreation | Science | Other | ||||||
---|---|---|---|---|---|---|---|---|---|---|
dict
instance is being used across all instances of your model. Trydefault=lambda: {}
. – univerio Aug 15 at 20:22