diff --git a/.gitignore b/.gitignore index cc63029..fc45463 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ dist/ downloads/ eggs/ .eggs/ -lib/ lib64/ parts/ sdist/ diff --git a/fuzzer/filldb.py b/fuzzer/filldb.py new file mode 100644 index 0000000..eac734d --- /dev/null +++ b/fuzzer/filldb.py @@ -0,0 +1,37 @@ +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()) diff --git a/fuzzer/datatypes.py b/lib/datatypes.py similarity index 100% rename from fuzzer/datatypes.py rename to lib/datatypes.py