From ac045bac2bf7cf803dd68f2df1568a66b0c5b6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Wed, 13 Dec 2023 14:41:53 +0100 Subject: [PATCH] chg: [configuration] Added default configuration file. --- CONTRIBUTING.md | 2 +- api/database.py | 14 +++++++++----- instance/example.py | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 instance/example.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca7976e..ea422ef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ security vulnerability. See our [security policy](https://github.com/scandale-project/pumpkin/security/policy) page. -[FastAPI](https://flask.palletsprojects.com) is used for the backend API. +[FastAPI](https://fastapi.tiangolo.com/) is used for the backend API. Please use [black](https://github.com/psf/black) for the syntax of your Python code. diff --git a/api/database.py b/api/database.py index 0590b74..9cbbad8 100644 --- a/api/database.py +++ b/api/database.py @@ -2,14 +2,18 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker +try: + from instance import config +except Exception: + from instance import example as config DB_CONFIG_DICT = { - "user": "cedric", - "password": "password", - "host": "localhost", - "port": 5432, + "user": config.DB_USERNAME, + "password": config.DB_PASSWORD, + "host": config.DB_HOST, + "port": config.DB_PORT, } -DATABASE_NAME = "pumpkin" +DATABASE_NAME = config.DB_NAME SQLALCHEMY_DATABASE_URI = "postgresql://{user}:{password}@{host}:{port}/{name}".format( name=DATABASE_NAME, **DB_CONFIG_DICT ) diff --git a/instance/example.py b/instance/example.py new file mode 100644 index 0000000..4707fee --- /dev/null +++ b/instance/example.py @@ -0,0 +1,5 @@ +DB_USERNAME = "" +DB_PASSWORD = "" +DB_HOST = "localhost" +DB_PORT = 5432 +DB_NAME = "pumpkin"