如何在 SQLAlchemy 中插入 NULL 值? [英] How to insert NULL value in SQLAlchemy?
本文介绍了如何在 SQLAlchemy 中插入 NULL 值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有以下列的 Table
:
I've a Table
with the following column:
Column('type', String(128))
如何在数据库中插入新行时将此列设置为 NULL?
How do I set this column to NULL when inserting a new row in database?
我尝试这样做:
self.type = NULL;
Python 中没有 NULL
类型,所以我不知道该怎么做.
There is no NULL
type in Python so I don't know how to do it.
推荐答案
而不是尝试
self.type = NULL
self.type = None
因为 Python 对 NULL 的等价物是 None.
As Python's equivalent for NULL is None.
这篇关于如何在 SQLAlchemy 中插入 NULL 值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文