Python MariaDB - Delete Query using PyMySQL Last Updated : 14 Oct, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report DELETE is an SQL query, that is used to delete one or more entries from a table with a given condition. To connect with MariaDB database server with Python, we need to import pymysql client. After connecting with the database in MySQL we can create tables in it and can manipulate them. Syntax: 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. Python3 import pymysql # Create a connection object # IP address of the MySQL database server Host = "localhost" # User name of the database server User = "user" # Password for the database user Password = "" database = "GFG" conn = pymysql.connect(host=Host, user=User, password=Password, database) # Create a cursor object cur = conn.cursor() query = f"DELETE FROM PRODUCT WHERE PRODUCT_TYPE = 'PRI'" cur.execute(query) # To commit the changes conn.commit() conn.close() Output : BeforeAfter In the above program, from table PRODUCT a single query is deleted from the table having the PRODUCT_TYPE attribute value PRI. Example 2: Let us look at another example for queries in a table. Python3 import pymysql # Create a connection object conn = pymysql.connect('localhost', 'user', 'password', 'database') # Create a cursor object cur = conn.cursor() query = f"DELETE FROM PRODUCT WHERE price < 2000" cur.execute(query) # To commit the changes conn.commit() conn.close() Output : BeforeAfter In the above program, from table PRODUCT a single query is deleted from the table where a price less than 2000. Comment More infoAdvertise with us Next Article Python MariaDB - Delete Query using PyMySQL P pratapworkmail Follow Improve Article Tags : Python Python-MariaDB Practice Tags : python Similar Reads Python MariaDB - Select Query using PyMySQL MariaDB is an open source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python. In this article we will look into the process of querying data from a table of the database using pymysql. Â To query data 2 min read Python MariaDB - Update Query using PyMySQL MariaDB is an open-source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python. In this article, we will look into the process of using the UPDATE query on a table of the database using pymysql. Â The up 2 min read Python MariaDB - Drop Table using PyMySQL MariaDB is an open source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python. In this article we will look into the process of Dropping a table from a database using pymysql. To drop a table use any o 2 min read Python MariaDB - Limit Clause using PyMySQL The Limit clause is used in SQL to control or limit the number of records in the result set returned from the query generated. By default, SQL gives out the required number of records starting from the top but it allows the use of the OFFSET keyword. OFFSET allows you to start from a custom row and 2 min read Python MySQL - Delete Query 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, Info 3 min read Like