Invalid syntax SELECT * {Guided Project: Analyzing CIA Factbook Data Using SQL - Step 2/3}

Screen Link:
https://app.dataquest.io/m/257/guided-project%3A-analyzing-cia-factbook-data-using-sql/3/overview-of-the-data

My Code:

%%capture
SELECT* 
FROM sqlite_master

%%capture
SELECT *
FROM fact
LIMIT 5

What I expected to happen:

It should be run and create an output

What actually happened:

  File "<ipython-input-7-7e642617a407>", line 1
    SELECT*
            ^
SyntaxError: invalid syntax

I followed the instruction but confused why it turn out an error, could anyone please explain?

Hi Anna,

You have to add a white space between SELECT and *.

1 Like

The instructions clarify this -

To run SQL queries in this project, we add %%sql on its own line to the start of our query. So to execute the query above, we’ll use the following code:

%%sql
SELECT *
  FROM sqlite_master
 WHERE type='table';

So, you need to run your statements with %%sql and not with %%capture at the top of the cell.

The following should run without issues -

%%sql
SELECT * 
FROM sqlite_master

Please note that you will have to run the queries in separate cells as well.

1 Like

Thanks so much, I see the issue now.

1 Like