MySQL with Python

  • Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python.
  • We can connect to a MySQL database hosted locally by using the package/module named;

mysql-connector-python module.

  • MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the Python Database API Specification.
  • It is written in pure Python and does not have any dependencies except for the Python Standard Library.
  • It provies a class called cursor.MySQLCursor. By using the various methods of this class, we can write and execute MySQL queries directly in Python IDE.

Code output:

Creating Database and Tables:

Screenshot (89)

Reading the Data:

Screenshot (90)
Screenshot (91)

Updating the Data:

Screenshot (92)

Deleting the Data:

Screenshot (93)


View Github