enter code hereI am trying to import the US.txt into my table but it fails and gives me this error message: CREATE TABLE places(...) failed: duplicate column name: sqlite>

This is how my table looks:

I can't see any duplicate here. Please, help. Column # Field Type Not NULL Default Value Primary Key Edit Delete 0 country_code TEXT Yes None No Edit Delete 1 postal_code TEXT Yes None No Edit Delete 2 place_name TEXT Yes None No Edit Delete 3 admin_name1 TEXT Yes None No Edit Delete 4 admin_code1 TEXT Yes None No Edit Delete 5 admin_name2 TEXT Yes None No Edit Delete 6 admin_code2 TEXT Yes None No Edit Delete 7 admin_name3 TEXT Yes None No Edit Delete 8 admin_code3 TEXT Yes None No Edit Delete 9 latitude NUMERIC Yes None No Edit Delete 10 longitude NUMERIC Yes None No Edit Delete 11 accuracy REAL Yes None No

2 Answers 2


From the FAQ section of the spec:

CREATE TABLE places(…​) failed: duplicate column name

If you see this message upon running .import in sqlite3, odds are you haven’t run sqlite3 in the same directory as mashup.db. If so, exit sqlite3 with .exit, cd to your mashup directory, and then re-run sqlite3 mashup.db.

It could also mean that you didn't create the table in the same directory that you are running the import from. This would happen if, for instance, you ran phpliteadmin or sqlite3 in the pset8 directory when you created the table, instead of mashup directory.

A thing to know about sqlite: if you try to access a database (as with phpliteadmin mashup.db and it doesn't exist, sqlite will create it. Bottom line, this means there are two mashup.db in different directories.

  • Thank you for your response, DinoCoderSaurus. I don't know how to a screen capture so I can show you what I have as my files. I have a mashup.db folder, a mashup.db file between helpers.py and readme.txt and a mashup.db file again after the US.txt file. Please, is that how it should be? May 20, 2017 at 9:06
  • Can't quite picture the directory structure from the description. The database file mashup.db must be in the mashup/ directory. Make sure you are in the mashup directory when you run sqlite3 to do the import. May 20, 2017 at 20:20

In case anyone else is looking for solutions that don't seem to work: make sure you named your table 'places', not 'places ' like I did... (notice the whitespace at the end)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .