update data
This commit is contained in:
parent
11871c8014
commit
71794010f5
3 changed files with 26 additions and 12 deletions
19
lib/database.py
Normal file
19
lib/database.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue