This commit is contained in:
Johannes Jöns 2024-01-24 16:14:43 +01:00
parent 30093eb03d
commit cb1cf6f6cf
3 changed files with 12 additions and 10 deletions

View file

@ -1,9 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from .database import db
import os import os
from dotenv import load_dotenv
import time import time
from dotenv import load_dotenv
from .database import db
async def startup(): async def startup():
load_dotenv() load_dotenv()
@ -12,6 +14,6 @@ async def startup():
await db.use("lf5", "lf5") await db.use("lf5", "lf5")
await db.query('DEFINE TABLE kunde SCHEMAFULL') await db.query('DEFINE TABLE kunde SCHEMAFULL')
await db.query('DEFINE FIELD kundenNr ON TABLE kunde TYPE string') await db.query('DEFINE FIELD kundenNr ON TABLE kunde TYPE string')
while(True): while True:
print(await db.query('SELECT * FROM kunde')) print(await db.query('SELECT * FROM kunde'))
time.sleep(5) time.sleep(5)

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
from surrealdb import Surreal
from dotenv import load_dotenv from dotenv import load_dotenv
from surrealdb import Surreal
load_dotenv() load_dotenv()
db = Surreal(f"ws://{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/rpc") db = Surreal(f"ws://{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/rpc")
# TODO: "SQL"-Prompts # TODO: "SQL"-Prompts

7
run.py
View file

@ -1,8 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import asyncio
from backend import startup from backend import startup
import asyncio
import os
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(startup()) asyncio.run(startup())