diff --git a/README.md b/README.md index 6013f69..b026b2a 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# LF5 Databes Project +# LF5 Database Project diff --git a/backend/__init__.py b/backend/__init__.py index c4f2375..ffd8949 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -1,7 +1,17 @@ #!/usr/bin/env python3 from .database import db import os +from dotenv import load_dotenv +import time + async def startup(): - await db.signin({"user": os.getenv('DB_USER'), "pass": os.getenv('DB_PW')}) - await db.use("test", "test") \ No newline at end of file + load_dotenv() + await db.connect() + await db.signin({"user": os.environ.get('DB_USER'), "pass": os.environ.get('DB_PW')}) + await db.use("lf5", "lf5") + await db.query('DEFINE TABLE kunde SCHEMAFULL') + await db.query('DEFINE FIELD kundenNr ON TABLE kunde TYPE string') + while(True): + print(await db.query('SELECT * FROM kunde')) + time.sleep(5) \ No newline at end of file diff --git a/backend/database.py b/backend/database.py index 644e625..c6ec188 100644 --- a/backend/database.py +++ b/backend/database.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 import os from surrealdb import Surreal +from dotenv import load_dotenv -db = Surreal(f"{os.getenv('DB_HOST')}:{os.getenv('DB_PORT')}") +load_dotenv() +db = Surreal(f"ws://{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/rpc") # TODO: "SQL"-Prompts \ No newline at end of file diff --git a/run.py b/run.py index 4428fc4..8eb8c53 100644 --- a/run.py +++ b/run.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from backend import startup -from dotenv import load_dotenv + import asyncio +import os if __name__ == "__main__": - load_dotenv() # Load User Variables asyncio.run(startup()) \ No newline at end of file