MySQL connecting string error in Jupyter Lab whenever I try to initiate a database on my M1 MacBook Pro

Viewed 15

System Specs

  • MacBook Pro 2021, M1 Pro
  • macOS Monterey

I have to use Jupyter lab to work with the Sakila database for my uni course. Every python/mysql package required for functionality is installed. I can work with the database through terminal without any issue. Whenever I try to create a connecting string to my database, the following error arrises.

Initial Error

%load_ext sql
%sql mysql://myUser:pass@localhost/sakila

Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])
name '_mysql' is not defined
Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])

Outcome of using pseudo data

%%sql

CREATE TABLE exercise_logs
    (id INTEGER PRIMARY KEY AUTO_INCREMENT,
    type TEXT,
    minutes INTEGER, 
    calories INTEGER,
    heart_rate INTEGER);

UsageError: Cell magic `%%sql` not found.
1 Answers

Instead of beginning the connecting string with

%sql mysql://myUser:pass@localhost/dbName

Replace 'mysql' and 'myUser' with 'mysql+pymysql' and 'root', respectively

%sql mysql+pymysql://root:pass@localhost/dbName
Related