Python Database API ( Application Program Interface ) is the Database interface for the standard Python. This standard is adhered to by most Python Database interfaces. There are various Database servers supported by Python Databases such as MySQL, GadFly, PostgreSQL, Microsoft SQL Server 2000, Informix, Interbase, Oracle, Sybase, etc. To connect with MySQL database server from Python, we need to import the
Below is a program to connect with MySQL database
The above program illustrates the connection with the MySQL database
geeks in which host-name is
localhost, the username is
user and password is
Deleting query from tables
After connecting with the database in MySQL we can create tables in it and can manipulate them.
DELETE FROM TABLE_NAME WHERE ATTRIBUTE_NAME = ATTRIBUTE_VALUE
Example 1: Below is a program to delete a query from the table in the database.
In the above program, a table named
STUDENT is created having attributes
AGE. Multiple data is inserted into the
STUDENT table and then a single query is deleted from the the table having the
ROLL attribute value
Example 2: Let us look at another example for queries in a table.
In the above program, another table is created in the
geeks database named
PHONE_RECORD having attribute
PHONE. Only one column is inserted into the table and then it is deleted using the
- Python MySQL - Update Query
- Python MySQL - Select Query
- Connect MySQL database using MySQL-Connector Python
- Python MySQL - Where Clause
- Python MySQL - Join
- MySQL-Connector-Python module in Python
- Python: MySQL Create Table
- Python MySQL - Order By Clause
- Python MySQL - Limit Clause
- Python MySQL - Insert into Table
- Python MySQL - Create Database
- Python MySQL - Drop Table
- How to install MySQL connector package in Python?
- Python MongoDB - Query
- Python MongoDB - create_index Query
- Python MongoDB - find_one Query
- Python MongoDB - insert_many Query
- Python MongoDB - Limit Query
- Python MongoDB - find_one_and_update Query
- Python MongoDB - find_one_and_delete Query
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.