fix database, add test scripts
This commit is contained in:
parent
ecc9903615
commit
9be6b0b290
4 changed files with 18 additions and 6 deletions
|
@ -1 +1 @@
|
||||||
# LF5 Databes Project
|
# LF5 Database Project
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from .database import db
|
from .database import db
|
||||||
import os
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
async def startup():
|
async def startup():
|
||||||
await db.signin({"user": os.getenv('DB_USER'), "pass": os.getenv('DB_PW')})
|
load_dotenv()
|
||||||
await db.use("test", "test")
|
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)
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
from surrealdb import Surreal
|
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
|
# TODO: "SQL"-Prompts
|
4
run.py
4
run.py
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from backend import startup
|
from backend import startup
|
||||||
from dotenv import load_dotenv
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
load_dotenv() # Load User Variables
|
|
||||||
asyncio.run(startup())
|
asyncio.run(startup())
|
Loading…
Reference in a new issue