我的表有以下列:
priority double precision DEFAULT 0.5::double precision,
created_at timestamp without time zone DEFAULT now(),但是对于刚刚插入的记录,值为null:

为什么不动呢?
更新:我已经将烧瓶-sqlalchemy行更新为:
priority = db.Column(db.Float, server_default=u'0.5', nullable=False)表中显示:
优先级双精度非空默认值0.5::双精度,
但现在它给出了一个错误:
sqlalchemy.exc.IntegrityError:(Kercopg2.IntegrityError)列“优先级”中的空值违反了null约束
发布于 2015-09-09 11:30:26
在数据库中向列添加一个NOT NULL约束。因此,当客户端尝试插入空值时,您会注意到:
priority double precision DEFAULT 0.5::double precision NOT NULL, 在客户机中,在执行插入时使用关键字DEFAULT而不是null:
INSERT INTO your_table (priority, created) VALUES (DEFAULT, DEFAULT);有关更多信息,请参见正式文档:http://www.postgresql.org/docs/9.3/static/sql-insert.html
https://stackoverflow.com/questions/32476107
复制相似问题