2 minutes
Databases MySQL: Integrate SQL in Jupyter Lab
Preparation of Jupyter Notebook
In the previous post we saw how to install MySQL and prepare the external programs needed to use SQL in our Jupyter Notebook.
Now let’s load the module and establish the connection and let’s start
How to create a table
Imagine that we want to build a database to identify pets. Every pet has an ID, a category (dog, cat, bird) and a name
* mysql+pymysql://user:***@localhost/datab
0 rows affected.
[]
How to add an entry
* mysql+pymysql://user:***@localhost/datab
1 rows affected.
1 rows affected.
1 rows affected.
[]
How to read data
* mysql+pymysql://user:***@localhost/datab
1 rows affected.
PetID | Name | Category |
---|---|---|
1 | Luna | Dog |
How to delete an entry
* mysql+pymysql://user:***@localhost/datab
1 rows affected.
[]
* mysql+pymysql://user:***@localhost/datab
2 rows affected.
PetID | Name | Category |
---|---|---|
1 | Luna | Dog |
2 | Silvester | Cat |
How to delete a table
* mysql+pymysql://user:***@localhost/datab
1 rows affected.
Tables_in_datab |
---|
Pets |
* mysql+pymysql://user:***@localhost/datab
0 rows affected.
[]
* mysql+pymysql://user:***@localhost/datab
0 rows affected.
Tables_in_datab |
---|
In this post we saw the basics operations of SQL, for more information you can go to SQLTutorial