async def get_author(self, *, author_id: int) -> Optional[models.Author]: row = (await self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": author_id})).first() if row is None: return None return models.Author( author_id=row[0], name=row[1], )
async def create_author(self, *, name: str) -> Optional[models.Author]: row = (await self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name})).first() if row is None: return None return models.Author( author_id=row[0], name=row[1], )