Python SQLite3 Module
Python SQLite3 Module
The Python SQLite3 module provides an interface for interacting with SQLite databases from Python programs.
Python DB API outlines a standard interface for connecting Python applications to relational databases like MySQL, SQLite, etc. This specification provides consistent methods and conventions for interacting with different database management systems (DBMS) from Python applications.
SQLite3 Module
The Python SQLite3 module helps us work with the SQLite database and allows database access. Using a Python application, we contact the SQLite Python module through SQLite operations. Then, the SQLite Python module executes the query on the SQLite database. After the query is executed, the result is fetched from the SQLite database, and the SQLite Python module delivers the result to the Python application.
- Use the connect() method of a sqlite3 module and pass the database name as an argument.
- Create a cursor object using the connection object returned by the connect method to execute SQLite queries from Python.
- Close the Cursor object and SQLite database connection object when work is done.
The above picture demonstrates how Python applications interact and access SQLite
databases adhering to Python Database API Specification. (PEP 249)
PEP stands for Python Enhancement Proposal.
A connection object is created using the .connect() method. When the database connection is open, we can interact and execute queries on the database using the cursor object. We can get the cursor object with the .cursor() method. The cursor can perform various operations with the .execute() statement. The connection must be closed at the end of the session with the .close() command.
SQLite Tutorials
SQLite tutorials on this website: