开发者

Insert Null value To an inet field in postgresql

I am trying to insert values to a table which contains two columns with inet types. When I try to insert a NULL value to these columns I get an er开发者_如何学编程ror saying

ERROR: invalid input syntax for type inet: ""

Actually I am triyng to do this from python using sqlalchemy but naturally I get the same error saying:

Session.commit() error: (DataError) invalid input syntax for type inet: ""

I need to be able to add null values to these columns. These colums do not have an attribute like NOT NULL.


The error message seems to indicate you are using an empty string to indicate a "null" value which is not correct.

The following should work:

INSERT INTO my_table (inet_column) VALUES (NULL);

Or if you actually mean update instead of insert:

UPDATE my_table
   SET inet_column = NULL
WHERE pk_column = 42;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜