Working in Jupyter Notebooks Locally

Screen Link:

My Code:

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

What I expected to happen:
I installed Anaconda and opened Jupyter Notebooks locally. I used the above suggested code from the Guided Project to load SQLite in the Jupyter Notebooks

What actually happened:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-16-fdbcafb7063a> in <module>
----> 1 get_ipython().run_line_magic('load_ext', 'sql')
      2 get_ipython().run_line_magic('sql', 'sqlite3:///factbook.db')

/opt/anaconda3/lib/python3.8/site-packages/IPython/core/ in run_line_magic(self, magic_name, line, _stack_depth)
   2324                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2325             with self.builtin_trap:
-> 2326                 result = fn(*args, **kwargs)
   2327             return result

<decorator-gen-64> in load_ext(self, module_str)

/opt/anaconda3/lib/python3.8/site-packages/IPython/core/ in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    189         if callable(arg):

/opt/anaconda3/lib/python3.8/site-packages/IPython/core/magics/ in load_ext(self, module_str)
     31         if not module_str:
     32             raise UsageError('Missing module name.')
---> 33         res =
     35         if res == 'already loaded':

/opt/anaconda3/lib/python3.8/site-packages/IPython/core/ in load_extension(self, module_str)
     78             if module_str not in sys.modules:
     79                 with prepended_to_syspath(self.ipython_extension_dir):
---> 80                     mod = import_module(module_str)
     81                     if mod.__file__.startswith(self.ipython_extension_dir):
     82                         print(("Loading extensions from {dir} is deprecated. "

/opt/anaconda3/lib/python3.8/importlib/ in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)

/opt/anaconda3/lib/python3.8/importlib/ in _gcd_import(name, package, level)

/opt/anaconda3/lib/python3.8/importlib/ in _find_and_load(name, import_)

/opt/anaconda3/lib/python3.8/importlib/ in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'sql'

Trying to figure out what is going wrong… any ideas what I need to change to get SQLite working locally and connect to the database? I downloaded the factbook.db database and stored it in the same local directory as the Jupyter notebook file

Hello @bc330,

The last line explains it all:

For RDBMS access via jupyter (like %sql), you will need to install ipython-sql.
Since you’re using anaconda, I suggest you install the module in your conda environment.

For some understanding, peek here
For conda installation, read here

Hope it works for you!