lf5/lib/database.py

20 lines
494 B
Python
Raw Permalink Normal View History

2024-02-08 09:33:59 +01:00
import os
from surrealdb import Surreal
from dotenv import load_dotenv
async def Database():
load_dotenv()
db = Surreal(f"ws://{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/rpc")
await db.signin({"user": os.environ.get('DB_USER'), "pass": os.environ.get('DB_PW')})
await db.use("lf5", "krautundrueben")
return db
async def load_init_data():
db = await Database()
query = open('../data/data.surrealql', 'r').read()
await db.query(query)
return