Written by Sümeyye Sever (notes I took while learning Python)
SQLite is a lightweight, serverless, self-contained database engine that is widely used for small to medium-sized applications. It's designed to be easy to set up and use, making it a popular choice for embedded systems, mobile applications, and local development.
main.py file import the sqlite3 moduleimport sqlite3
db = sqlite3.connect("books-collection.db")
Run main.py and you should see a new file appear in PyCharm called books-collection.db
Next we need to create a cursor which will control our database.
cursor = db.cursor()
So a cursor is also known as the mouse or pointer. If we were working in Excel or Google Sheet, we would be using the cursor to add rows of data or edit/delete data, we also need a cursor to modify our SQLite database.
cursor.execute("CREATE TABLE books (id INTEGER PRIMARY KEY, title varchar(250) NOT NULL UNIQUE, author varchar(250) NOT NULL, rating FLOAT NOT NULL)")