From 6ea2a00bfef96bf929b0205a36c1a917476d8abb Mon Sep 17 00:00:00 2001 From: Justin Ludwig Date: Thu, 28 Dec 2023 17:23:17 -0800 Subject: [PATCH] Update SQLAlchemy compatibility and dependencies - Added psycopg2-binary to requirements for PostgreSQL support. - Refactored consumer.py to use joinedload with the correct syntax. - Updated models.py to fix ForeignKey and Enum type definitions for better compatibility with current SQLAlchemy versions. These changes ensure the application is compatible with the latest SQLAlchemy practices and supports PostgreSQL databases. --- requirements.txt | 1 + wallabag_kindle_consumer/consumer.py | 2 +- wallabag_kindle_consumer/models.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a4fe7e2..42cac36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ aiohttp_jinja2 aiohttp sqlalchemy logbook +psycopg2-binary diff --git a/wallabag_kindle_consumer/consumer.py b/wallabag_kindle_consumer/consumer.py index d11f92c..27e1b2e 100644 --- a/wallabag_kindle_consumer/consumer.py +++ b/wallabag_kindle_consumer/consumer.py @@ -60,7 +60,7 @@ class Consumer: await asyncio.gather(*fetches) session.commit() - jobs = [self.process_job(job, session) for job in session.query(Job).options(joinedload('user'))] + jobs = [self.process_job(job, session) for job in session.query(Job).options(joinedload(Job.user))] await asyncio.gather(*jobs) session.commit() diff --git a/wallabag_kindle_consumer/models.py b/wallabag_kindle_consumer/models.py index 558b7a2..237a4cf 100644 --- a/wallabag_kindle_consumer/models.py +++ b/wallabag_kindle_consumer/models.py @@ -28,8 +28,8 @@ class Job(Base): id = Column(Integer, primary_key=True, autoincrement=True) article = Column(Integer) title = Column(String) - user_name = Column(Integer, ForeignKey("user.name")) - format = Column(Enum('pdf', 'mobi', 'epub')) + user_name = Column(String, ForeignKey("user.name")) + format = Column(Enum('pdf', 'mobi', 'epub', name='format_enum')) class ContextSession: