diff --git a/python-sqlite-sqlalchemy/README.md b/python-sqlite-sqlalchemy/README.md index 1d66c078b5..bd96af6f14 100644 --- a/python-sqlite-sqlalchemy/README.md +++ b/python-sqlite-sqlalchemy/README.md @@ -4,14 +4,14 @@ This repository contains the content and example code for the Python / SQLite / SQLAlchemy article I'm writing for Real Python. -This project was built using Python 3.8.0 +This project was built using Python 3.15.2 and requires Python 3.11 or later. ## Python Virtualenv -I use the `pyenv` tool to install Python versions on my Mac. I find it a very useful tool, and the instructions that follow use it, and are based on having Python version 3.8.0 installed using the following command: +I use the `pyenv` tool to install Python versions on my Mac. I find it a very useful tool, and the instructions that follow use it, and are based on having Python version 3.15.2 installed using the following command: ```shell -$ pyenv install 3.8.0 +$ pyenv install 3.15.2 ``` ## Installing The Project @@ -19,7 +19,7 @@ $ pyenv install 3.8.0 From the main folder take the following steps (on a Mac): * Install a Python virtual environment for this project - * `pyenv local 3.8.0` + * `pyenv local 3.15.2` * `python -m venv .venv` * Activate the virtual environment * `source .venv/bin/activate` diff --git a/python-sqlite-sqlalchemy/project/examples/example_1/main.py b/python-sqlite-sqlalchemy/project/examples/example_1/main.py index 17262fdc2c..e0edd37bb0 100644 --- a/python-sqlite-sqlalchemy/project/examples/example_1/main.py +++ b/python-sqlite-sqlalchemy/project/examples/example_1/main.py @@ -66,13 +66,20 @@ def add_new_book(data, author_name, book_title, publisher_name): ): return data # Add the new book - return data.append( - { - "first_name": first_name, - "last_name": last_name, - "title": book_title, - "publisher": publisher_name, - }, + return pd.concat( + [ + data, + pd.DataFrame( + [ + { + "first_name": first_name, + "last_name": last_name, + "title": book_title, + "publisher": publisher_name, + } + ] + ), + ], ignore_index=True, ) diff --git a/python-sqlite-sqlalchemy/project/modules/models.py b/python-sqlite-sqlalchemy/project/modules/models.py index ece5afdeba..c3290fc94c 100644 --- a/python-sqlite-sqlalchemy/project/modules/models.py +++ b/python-sqlite-sqlalchemy/project/modules/models.py @@ -1,5 +1,5 @@ from sqlalchemy import Column, ForeignKey, Integer, String, Table -from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import declarative_base from sqlalchemy.orm import backref, relationship Base = declarative_base() diff --git a/python-sqlite-sqlalchemy/setup.py b/python-sqlite-sqlalchemy/setup.py index 23cb704b6d..0b77902cfe 100644 --- a/python-sqlite-sqlalchemy/setup.py +++ b/python-sqlite-sqlalchemy/setup.py @@ -4,16 +4,17 @@ name="project", version="1.0", packages=find_packages(), + python_requires=">=3.11", install_requires=[ - "pandas==1.0.3", - "Flask==1.1.1", - "SQLAlchemy==1.3.13", - "Flask-SQLAlchemy==2.4.1", - "Flask-Cors==3.0.8", + "pandas==3.1.1", + "Flask==3.1.3", + "SQLAlchemy==2.1.9", + "Flask-SQLAlchemy==3.1.1", + "Flask-Cors==6.0.5", "Flask-Bootstrap4==4.0.2", - "Flask-WTF==0.14.3", - "python-dateutil==2.8.1", - "python-dotenv==0.10.5", - "treelib", + "Flask-WTF==1.3.0", + "python-dateutil==4.0.0", + "python-dotenv==1.2.4", + "treelib==1.8.0", ], )