Database operations with Python
In this section, we are going to read a table using Python. To execute a Python function, we will use PyCharm on a local computer. Carry out the following steps:
- Open PyCharm or an IDE, whichever you prefer.
- We are going to install MySQL Connector to PyCharm. MySQL Connector will be used for database operations from Python. In PyCharm, select File | New Projects Setup | Preferences for New Projects…:
Figure 8.28 – Preferences
- In the panel, select Python Interpreter:
Figure 8.29 – Python Interpreter
- To add a new package, click the + symbol:
Figure 8.30 – Adding a package
- In the upcoming panel, type
mysql-conn
to install mysql-connector. You will be able to see mysql-connector. Click Install Package to install it:
Figure 8.31 – Installing mysql-connector
-
...