diff options
Diffstat (limited to 'edaweb/database.py')
| -rw-r--r-- | edaweb/database.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/edaweb/database.py b/edaweb/database.py index dab56e7..c6553a6 100644 --- a/edaweb/database.py +++ b/edaweb/database.py @@ -20,8 +20,11 @@ class Database: passwd:str = None def __enter__(self): + config_path = os.path.join(os.path.dirname(__file__), "..", "edaweb.conf") + if not os.path.exists(config_path): + raise FileNotFoundError("Could not find edaweb.conf config file") self.config = configparser.ConfigParser(interpolation = None) - self.config.read(os.path.join(os.path.dirname(__file__), "edaweb.conf")) + self.config.read(config_path) if self.safeLogin: self.__connection = pymysql.connect( @@ -44,7 +47,7 @@ class Database: def get_header_links(self): with self.__connection.cursor() as cursor: - cursor.execute("SELECT name, link FROM headerLinks ORDER BY name;") + cursor.execute("SELECT name, link FROM headerLinks WHERE display = true ORDER BY name;") return cursor.fetchall() def get_image(self, imageName): @@ -64,7 +67,7 @@ class Database: def get_header_articles(self): with self.__connection.cursor() as cursor: - cursor.execute("SELECT articleName, link FROM headerArticles;") + cursor.execute("SELECT articleName, link FROM headerArticles WHERE display = true;") return cursor.fetchall() def get_all_categories(self): |
