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.
This commit is contained in:
Justin Ludwig 2023-12-28 17:23:17 -08:00
parent 2afbf652dc
commit 6ea2a00bfe
3 changed files with 4 additions and 3 deletions

View File

@ -5,3 +5,4 @@ aiohttp_jinja2
aiohttp
sqlalchemy
logbook
psycopg2-binary

View File

@ -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()

View File

@ -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: