<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_post_by_id(self, post_id):
 """ Fetch the blog post given by ``post_id`` :param post_id: The post identifier for the blog post :type post_id: str :return: If the ``post_id`` is valid, the post data is retrieved, else returns ``None``. """

        r = None
        post_id = _as_int(post_id)
        with self._engine.begin() as conn:
            try:
                post_statement = sqla.select([self._post_table]) \
                    .where(self._post_table.c.id == post_id) \
                    .alias('post')

                joined_statement = post_statement.join(self._tag_posts_table) \
                    .join(self._tag_table) \
                    .join(self._user_posts_table) \
                    .alias('join')

                # Note this will retrieve one row per tag
                all_rows = conn.execute(
                    sqla.select([joined_statement])
                ).fetchall()
                r = self._serialise_posts_and_tags_from_joined_rows(
                    all_rows
                )[0]

            except Exception as e:
                self._logger.exception(str(e))
                r = None
        return r