Distinguish between MySQL the server and
the mysql
client. We never talk to the server directly;
we always need an intermediary. (This is starting to sound
quasi-religious.)
The PyMysql
Python module allows our Python
program to talk to the server, just like the mysql
client allows a human to talk to the server.
Sure. The database server already exists; I installed and configured that software long ago. I created database was created earlier this semester, at the same time that I set up your MySQL username and password.
Your python program connects to the server and uses
a cursor to run queries, just like you did with
the mysql
client.
Yes, we use cursors to get data from databases. No, there's no other way to do it.
The second query would overwrite the first. If you need to have two simultaneous queries, use two cursors. They're inexpensive.