Python Create SQLite Cursor
Python Create SQLite Cursor
An SQLite Cursor is an object that allows you to interact with the SQLite database. You execute SQL commands through the cursor from within the Python program code.
Create SQLite Cursor
connection.cursor([ optional cursorClass])
The above function call creates a cursor that can be used for database programming with Python program. This method accepts a single optional parameter, cursorClass. If supplied, this must be a custom cursor class that extends sqlite3.Cursor.
Example
To create a cursor, we must open a database connection for the SQLite database. The details to open a database connection are listed here.
# Create a cursor
cursor = connection.cursor()
Executing SQL Query
After creating the cursor object, we can use the cursor’s execute() method to run SQL queries.
cursor.execute(”SQL query”)
Commit Changes
After executing SQL statements, you need to commit the changes to make them permanent.
connection.commit()
—
Python Tutorials
Python Tutorial on this website can be found at:
https://www.testingdocs.com/python-tutorials/
More information on Python is available at the official website: