From 6012998ecf70d9ad5e6c86c57270342952de0a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Mon, 28 Mar 2022 01:30:37 +0000 Subject: [PATCH] don't play with new db --- api/kiwi_vpn_api/main.py | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/api/kiwi_vpn_api/main.py b/api/kiwi_vpn_api/main.py index a4a171d..4730d7e 100755 --- a/api/kiwi_vpn_api/main.py +++ b/api/kiwi_vpn_api/main.py @@ -13,11 +13,8 @@ import uvicorn from fastapi import FastAPI from .config import Config, Settings -from .db import Connection # from .db.schemata import User -from .db_new import Capability -from .db_new import Connection as Connection_new -from .db_new import Device, User +from .db_new import Connection from .routers import main_router settings = Settings.get() @@ -47,46 +44,13 @@ async def on_startup() -> None: # check if configured if (current_config := await Config.load()) is not None: # connect to database - Connection.connect(await current_config.db.db_engine) + Connection.connect("sqlite:///tmp/v2.db") # # some testing # with Connection.use() as db: # print(User.from_db(db, "admin")) # print(User.from_db(db, "nonexistent")) - Connection_new.connect("sqlite:///tmp/v2.db") - - User.create( - name="Uwe", - password_clear="ulf", - email="uwe@feh.de", - ) - - print(User.get(name="Uwe")) - print(User.authenticate("Uwe", "uwe")) - - uwe = User.authenticate("Uwe", "ulf") - - uwe.set_capabilities([Capability.admin]) - uwe.update() - print(uwe.get_capabilities()) - - uwe.set_capabilities([]) - uwe.update() - print(uwe.get_capabilities()) - - with Connection_new.session as db: - db.add(uwe) - print(uwe.devices) - - ipad = Device.create( - owner_name="Uwe", - name="iPad", - type="tablet", - ) - # ipad = Device. - print(ipad) - def main() -> None: uvicorn.run(