import string from dataclasses import fields from surrealdb import Surreal import random from lib.datatypes import Customer async def mainold(): """Example of how to use the SurrealDB client.""" async with Surreal("ws://localhost:8000/rpc") as db: await db.signin({"user": "root", "pass": "root"}) await db.use("test", "test") for k in range(1, 20): await db.create( "Kunde", fill_data().dict(), ) def randomword(length): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(length)) def fill_data(): data = Customer(1, "a", "a", "a", "a", "a", 1, "a", 1, "a") for var in fields(Customer): if var.type == type("str"): setattr(data, var.name, randomword(random.randint(1, 20))) elif var.type == type(1): setattr(data, var.name, random.randint(0, 100)) return data print(fill_data())