Add image cache generation

This commit is contained in:
Michał Gdula 2023-03-26 20:58:17 +00:00
parent 2b795e520f
commit de79f5bc54
11 changed files with 126 additions and 96 deletions

View file

@ -13,6 +13,7 @@ USER_DIR = platformdirs.user_config_dir('onlylegs')
DB_PATH = os.path.join(USER_DIR, 'gallery.sqlite')
# In the future, I want to add support for other databases
# engine = create_engine('postgresql://username:password@host:port/database_name', echo=False)
# engine = create_engine('mysql://username:password@host:port/database_name', echo=False)
engine = create_engine(f'sqlite:///{DB_PATH}', echo=False)
@ -59,6 +60,7 @@ class Posts (base): # pylint: disable=too-few-public-methods, C0103
post_alt = Column(String, nullable=False)
junction = relationship('GroupJunction', backref='posts')
thumbnail = relationship('Thumbnails', backref='posts')
class Thumbnails (base): # pylint: disable=too-few-public-methods, C0103
@ -70,7 +72,8 @@ class Thumbnails (base): # pylint: disable=too-few-public-methods, C0103
id = Column(Integer, primary_key=True)
file_name = Column(String, unique=True, nullable=False)
file_ext = Column(String, nullable=False)
data = Column(PickleType, nullable=False)
resolution = Column(PickleType, nullable=False)
post_id = Column(Integer, ForeignKey('posts.id'))
class Groups (base): # pylint: disable=too-few-public-methods, C0103