How to insert a NULL value in SQLAlchemy?

I have a Table with the following column:

 Column('type', String(128)) 

How to set this column to NULL when inserting a new row into the database?

I tried to do this:

 self.type = NULL; 

There is no NULL type in Python, so I don't know how to do this.

+6
source share
2 answers

Instead of trying

 self.type = NULL 

try the Yaroslavl administrator suggested

 self.type = None 

Since the Python equivalent for NULL is None.

+13
source

I know this is an old thread, but it worked for me.

 self.type = sqlalchemy.sql.null() 
0
source

All Articles