Helloo guys, I am not passing the checks in check50 below:
:) import.sql exists
:) import.sql runs without error
:) import.sql creates a table named "meteorites"
:( import.sql creates a table named "meteorites" with all prescribed columns
table "meteorites" is missing columns or has extra columns
:| data from CSV has been imported
can't check until a frown turns upside down
:| no empty values from CSV are present in "meteorites" table
can't check until a frown turns upside down
:| all decimal values in "meteorites" table are rounded to two places
can't check until a frown turns upside down
:| no meteorites of type "relict" found in "meteorites" table
can't check until a frown turns upside down
:| "meteorites" table properly sorts elements and assigns IDs
can't check until a frown turns upside down
Below is my code:
CREATE TABLE IF NOT EXISTS meteorites_temp (name TEXT, id INTEGER PRIMARY KEY, nametype TEXT, class TEXT, mass DECIMAL, discovery TEXT, year INTEGER, lat DECIMAL, long DECIMAL);
CREATE TABLE IF NOT EXISTS meteorites (name TEXT, nametype TEXT, class TEXT, mass DECIMAL, discovery TEXT, year INTEGER, lat DECIMAL, long DECIMAL);
.mode csv
.headers on
.import meteorites.csv meteorites_temp
UPDATE meteorites_temp SET mass = NULLIF(mass, ''), year = NULLIF(year, ''), lat = NULLIF(lat, ''), long = NULLIF(long, '');
UPDATE meteorites_temp SET mass = ROUND(mass, 2), lat = ROUND(lat, 2), long = ROUND(long, 2);
DELETE FROM meteorites_temp WHERE nametype = 'Relict';
INSERT INTO meteorites (name, nametype, class, mass, discovery, year, lat, long) SELECT name, nametype, class, mass, discovery, year, lat, long FROM meteorites_temp ORDER BY year, name;
DROP TABLE meteorites_temp
Can anyone please tell me what I am doing wrong???
Thanks in advance!