from cfg import config import sql def _get_page_id(title, connection): cursor = connection.cursor() cursor.execute(sql.statements["get_page_id"], (title,)) return cursor.fetchone() def get_page_id(title, connection): result = _get_page_id(title, connection) if(result is not None): return result[0] cursor = connection.cursor() cursor.execute(sql.statements["insert_page"], (title,)) return _get_page_id(title, connection)[0] def get_page_title(page_id, connection): cursor = connection.cursor() cursor.execute(sql.statements["get_page_title"], (page_id,)) return cursor.fetchone()[0]