fix database, add test scripts

This commit is contained in:
hilfe 2024-01-24 15:39:03 +01:00
parent ecc9903615
commit 9be6b0b290
4 changed files with 18 additions and 6 deletions

View file

@ -1 +1 @@
# LF5 Databes Project
# LF5 Database Project

View file

@ -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")
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)

View file

@ -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

4
run.py
View file

@ -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())