lf5/fuzzer/filldb.py
2024-02-08 09:33:59 +01:00

34 lines
771 B
Python

import string
from dataclasses import fields
import random
from lib.database import Database
from lib.datatypes import Customer
async def mainold():
db = await Database()
for k in range(1, 20):
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())