How to connect to an sqlite database using sql magic command and ipython-sql

When try to load database(chinook.db) on local machine in jupyter notebook , not able to load the same.
See attached screenshot of my code.

Pls help to resolve issue.
thanks in advance…
Umesh

1 Like

I got the solution.

this works %sql sqlite:////Users/umesh/Downloads/chinook.db instead of %sql sqlite:////chinook.db

thanks

1 Like

Hi @exports,

Either you have to use the absolute path of the database file or place the file in the same folder as the notebook file and use the relative path. For easiness, let’s place them in the same folder.

  1. Create a new folder
  2. Place chinook.db in that folder
  3. Launch Jupyter
  4. Navigate to the folder
  5. Create a new Python 3 notebook

Shared with CloudApp

After that try running these:

%%capture
%load_ext sql
%sql sqlite:///chinook.db
%%sql
SELECT
    name
FROM
    sqlite_master
WHERE
    type='table'

Best,
Sahil

1 Like

What a timing! you found the solution when I was typing it :sweat_smile:

:smile:
thanks a lot

1 Like

This did not work. Instead it overwrites the existing database with a blank database. What can I do to fix this?