This repo demonstrates how to interact with an SQLite database using two different approaches in Python:
- Directly using SQLite with the
sqlite3
module. - Using SQLAlchemy, an Object-Relational Mapping (ORM) library.
The project contains the following files:
sqlite_example.py
: A Python script demonstrating basic SQLite database operations.sqlalchemy_example.py
: A Python script demonstrating database operations using SQLAlchemy ORM.README.md
: This file, providing an overview and instructions for using the examples.
Before running the examples, ensure you have Python installed on your system. You will also need to install SQLAlchemy if you plan to use the sqlalchemy_example.py
script. You can install it using pip:
pip install sqlalchemy
sqlite_example.py
demonstrates how to perform basic database operations using SQLite directly.
- The script will create a file named
library.db
in the same directory. - It will create a table named
books
with columns forid
,title
,author
, andpublication_year
.
- The script inserts a sample book into the
books
table.
- It retrieves and prints all entries in the
books
table.