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
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course