8

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 error 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.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Alptugay
  • 1,676
  • 4
  • 22
  • 29

1 Answers1

11

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;