UNIQUE constraint failed: mytable.hostName

I have created my own table called mytable in sqlite and want to capture content of a list of my hosts and write them into table. I can get content of pages with python-requests but while reaching to a host the following error occurs:

UNIQUE constraint failed: mytable.hostName

Is this a problem with my table while creating it? I am creating the table like so:

> CREATE TABLE mytable (host CHAR(20) PRIMARY KEY, content TEXT);

UPDATE

I removed my db completely and run my code again. but there is also the same error....


You have:

CREATE TABLE mytable (host CHAR(20) PRIMARY KEY, content TEXT);

PRIMARY KEY has to be UNIQUE. You probably try to insert the same key twice like:

INSERT INTO mytable(host, content) 
VALUES ('a', 'some text');
-- OK

INSERT INTO mytable(host, content) 
VALUES ('a', 'some text 2');
-- Error: UNIQUE constraint failed: mytable.host

SqlFiddleDemo

Before you insert data you should check if it's existed already.