Home > Blockchain >  Flask SqlAlchemy: Returning None for JSON type inserts 'null' string, not real NULL
Flask SqlAlchemy: Returning None for JSON type inserts 'null' string, not real NULL

Time:04-08

I'm using Flask SqlAlchemy. I'm inserting data into a Postgres DB and there is a JSON column type. When there is no data, I return None with the intention that that will set NULL into the column. This is what's suggested enter image description here

CodePudding user response:

What you describe is the default behavior.

The JSON and JSONB column type can be initialized with the parameter none_as_null set to True. This parameter is by default False.

The documentation for reference.

  • Related