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

Screen Link:


My Code:

# Connecting Jupyter Notebook to database file
%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.


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

import sqlite3

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:

%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.