Not able to connect to SQL database for guided project in sql fundamentals

Screen Link:
http://localhost:8888/tree/Desktop/Guided%20Project_%20Analyzing%20CIA%20Factbook%20Data%20Using%20SQL

http://localhost:8888/notebooks/Desktop/Guided%20Project_%20Analyzing%20CIA%20Factbook%20Data%20Using%20SQL/analyzing_cia_factbook_data_using_sql.ipynb

My Code:

# Connecting Jupyter Notebook to database file
%%capture
%load_ext sql
%sql sqlite:///factbook.db

What I expected to happen:

What actually happened:

UsageError: Line magic function `%%capture` not found.

I have the notebook in the same place as the file needed and still got the error. I restarted the kernel and ran the code again and still had issues. I double checked that python-sql was installed in my anaconda environment and it is.

@vma2324

You can use this to check the version of sqlite3 that you have.

import sqlite3
sqlite3.version

People are of the opinion that sqlite3 is now part of the standard python library. No need for installation. Check here to see the discussion.

Also do not put anything before the %%. It works like this:

%%capture
%load_ext sql
%sql sqlite:///factbook.db

This happens because of the comment you’ve placed before %%capture, place the comment after the magic command.

2 Likes