[Psycopg] INET type and arrays: too much casting?
Stephane Bortzmeyer
bortzmeyer at nic.fr
Mon Sep 15 12:27:49 CEST 2008
If I create a table:
CREATE TABLE Foobar (addr INET);
psycopg2 can write data just fine:
>>> cursor.execute("""INSERT INTO Foobar VALUES (%s)""", ["2001::1"])
>>>
But if the column has an array type:
CREATE TABLE Foobar (addr INET[]);
psycopg2 can no longer insert data:
>>> cursor.execute("""INSERT INTO Foobar VALUES (%s)""", [["2001::1", "2001:db8::dead:babe"]])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
psycopg2.ProgrammingError: column "addr" is of type inet[] but expression is of type text[]
HINT: You will need to rewrite or cast the expression.
More information about the Psycopg
mailing list