Add database functions
This commit is contained in:
@@ -10,18 +10,17 @@ from auth import create_user
|
||||
|
||||
APP_ENV = os.environ.get("APP_ENV", "dev")
|
||||
logger = setup_logging(APP_ENV)
|
||||
|
||||
logger.info(f"Starting migration - APP-Version {__version__}")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parents[1]
|
||||
DB_DIR = BASE_DIR / "data"
|
||||
DB_DIR = BASE_DIR / "app" / "app_db"
|
||||
DB_PATH = DB_DIR / "app.db"
|
||||
MIGRATIONS_DIR = BASE_DIR / "migrations"
|
||||
ADMIN_USERNAME = "admin"
|
||||
|
||||
print(BASE_DIR)
|
||||
|
||||
def get_connection() -> sqlite3.Connection:
|
||||
DB_DIR.mkdir(exist_ok=True)
|
||||
@@ -91,6 +90,11 @@ def admin_exists() -> bool:
|
||||
"SELECT 1 FROM users WHERE username = ?",
|
||||
(ADMIN_USERNAME,),
|
||||
).fetchone()
|
||||
if row is not None:
|
||||
print(row[0])
|
||||
else:
|
||||
print(ADMIN_USERNAME)
|
||||
print("Kein Admin gefunden")
|
||||
return row is not None
|
||||
|
||||
|
||||
@@ -111,9 +115,9 @@ def create_admin_user():
|
||||
ok = create_user(
|
||||
username=ADMIN_USERNAME,
|
||||
password=pw1,
|
||||
role="admin",
|
||||
role_id=1,
|
||||
email="admin@co_app",
|
||||
firstname="co_app",
|
||||
firstname="***",
|
||||
lastname="admin"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user