Https://www.codecademy.com/paths/web-development/tracks/sql-for-web-development/modules/project-gold-medal-metrics/informationals/bapi-p5-gold-medal-metrics

https://www.codecademy.com/paths/web-development/tracks/sql-for-web-development/modules/project-gold-medal-metrics/informationals/bapi-p5-gold-medal-metrics

I have typed in ‘npm install’, I have typed ‘npm run webpack’ both have worked fine. But how do I then open the index file? it says follow these commands with ‘open index.html’.
This is not working… How do I view it? I can click on the file in my file explorer but this opens the HTML file not on the localhost.

How do I check that the SQL functions are working?

3 Likes

This took me a while to figure out and there’s probably a better way.

In server.js, I added:
app.use(express.static('public'); //line 13 below the CORS expression

I then made a new folder called /public

Then I moved /build, /css, /img, index.html, and index.js into the /public folder.

Open the recently moved index.js and add a period to the app import so it goes up one level:

import App from '../App'; // replace line 3

Reload the server, open localhost:3001, and it worked!

1 Like

I have also found it easy to test queries out using the DB Browser. Just open the sqlite data file and test queries there before saving the code.

Hello, I am kind of lost on this project. I downloaded the zip file, but the gold_medals.sqlite file is empty, so I cannot run it in DB Browser SQLite to test my queries. Any help would be much appreciated.
Also, are there any tips for writing the SQL strings in the sql.js file. I found that if I use different lines, I get major syntax errors.

cheers, Mark

1 Like

You can run “open index.html” in the terminal, from the projects root folder, in order to open the file.

Once you have completed “createCountryTable”, and createGoldMedalTable functions, and restart the server, you should be able to see the data in the website (as well as the gold_medals.sqlite file via the DB Browser for SQLite program).

Once you have finished writing the function, you can restart the server, and run “npm test” in your terminal, from the projects root folder.

In the test output you can check out if the functions passed the tests.

Good luck!

1 Like

Just as a clarification for others that have just started with this project, you need to finish the two first functions and restart the server, before there will be any data in the “gold_medals.sqlite” file.

1 Like

Hi! You gotta finish the two first functions and restart the server, before there will be any data present in the gold_medals.sqlite file.

Here comes an example from the complete first function:

const createCountryTable = () => {
  return `CREATE TABLE Country (
    name TEXT NOT NULL,
    code TEXT NOT NULL,
    gdp INTEGER,
    population INTEGER);`;
};

P.S. You can always peek in the solution code if you get stuck:
https://www.codecademy.com/paths/web-development/tracks/sql-for-web-development/modules/project-gold-medal-metrics/informationals/bapi-p5-gold-medal-metrics-solution

Good luck!

1 Like

@mrbaker1917 did this get you unstuck?

For those that follow the commands differ by platform. In Windows for example, type start index.html NOT open.

6 Likes

start index.html just starts the file in the browser. Since the page is loaded not from the server it has no access to databases…

For anybody experiencing the issue described above, there are two CSV files in the ‘data’ folder of the starter code. Within DB browser, choose File > Import > Table from CSV file for each file.

Once imported, you can test your solutions from the Execute SQL tab.

1 Like

Thank you, thank you, thank you!!! :slight_smile: