Deleting Data
For deleting the data from the SQLite3 table we can use the delete command.
DELETE FROM table_name [WHERE Clause]
Example: Deleting from SQLite3 table using Python
Python3
# Import module import sqlite3 # Connecting to sqlite conn = sqlite3.connect( 'gfg.db' ) # Creating a cursor object using # the cursor() method cursor = conn.cursor() # Updating cursor.execute( '''DELETE FROM emp WHERE fname="Rishabh";''' ) # Commit your changes in the database conn.commit() # Closing the connection conn.close() |
Output:
SQL using Python
In this article, integrating SQLite3 with Python is discussed. Here we will discuss all the CRUD operations on the SQLite3 database using Python. CRUD contains four major operations –
Note: This needs a basic understanding of SQL.
Here, we are going to connect SQLite with Python. Python has a native library for SQLite3 called sqlite3. Let us explain how it works.