async def delete_session_by_id(self, session_id: str):
        async with self.database_service.instance.acquire() as connection:
            result = await connection.execute(
                sessions.delete().where(sessions.c.session_id == session_id))

            if result.rowcount == 0:
                raise DBRecordNotFoundError('Session with id ' + session_id +
                                            ' was not found.')
    async def delete_category(self, category_id: int):
        async with self.database_service.instance.acquire() as conn:
            result = await conn.execute(categories.delete().where(
                categories.c.category_id == category_id))

            if result.rowcount == 0:
                raise DBRecordNotFoundError('Tag with id ' + str(category_id) +
                                            ' was not found.')
    async def delete_user_by_email(self, email: str):
        async with self.database_service.instance.acquire() as conn:
            result = await conn.execute(
                users.delete().where(users.c.client_email == email))

            if result.rowcount == 0:
                raise DBRecordNotFoundError('Client with email ' + str(email) +
                                            ' was not found.')
    async def delete_user_by_id(self, client_id: int):
        async with self.database_service.instance.acquire() as conn:
            result = await conn.execute(
                users.delete().where(users.c.client_id == client_id))

            if result.rowcount == 0:
                raise DBRecordNotFoundError('Client with client_id ' +
                                            str(client_id) + ' was not found.')
    async def get_user_session_by_id(self, session_id: str):
        async with self.database_service.instance.acquire() as connection:
            session = await connection.execute(
                sessions.select().where(sessions.c.session_id == session_id))

            if session.rowcount == 0:
                raise DBRecordNotFoundError('Session with id ' + session_id +
                                            ' was not found.')

            return dict(await session.fetchone())
Exemple #6
0
    async def get_by_slug(self, slug: str, lang: str):
        async with self.database_service.instance.acquire() as connection:
            post_result = await connection.execute(
                posts.select().where(posts.c.post_slug == slug)
            )

            if post_result.rowcount == 0:
                raise DBRecordNotFoundError('Post with slug ' + slug + ' was not found')

            return await self.do_get_post(post_result, lang)