Пример #1
0
def importToSupplier():
    try:
        dsnStr = cx_Oracle.makedsn("217.173.198.135", "1522", "orcltp")
        con = cx_Oracle.connect(user="******", password="******", dsn=dsnStr)
        num = int(input("How many rows should be entered? "))
        last_id = getLastID("supplier")
        print("Fetching rows...")
        for x in range(num):
            a = mimesis.Address('en')
            p = mimesis.Person('en')
            b = mimesis.Business('en')
            address = a.city()
            name = b.company()
            print(name)
            contact_person = p.full_name()
            phone = p.telephone()
            email = p.email(domains=['mail.com'])
            query = "INSERT INTO supplier (id_supplier, address, name, contact_person, phone, email) VALUES  (:1, :2, " \
                    ":3, :4, :5, :6) "
            cursor = con.cursor()
            last_id = last_id + 1
            cursor.execute(
                query, (last_id, address, name, contact_person, phone, email))
            print(query)
            cursor.close()
        con.commit()
        print("Rows added successfully")
    except cx_Oracle.Error as error:
        print("Error occurred:")
        print(error)
    consoleInput()
Пример #2
0
def next_owner(data_locale: str) -> typing.Iterator[Owner]:
    personal = mimesis.Person(data_locale)
    address = mimesis.Address(data_locale)
    owner_id = 0

    while True:
        owner_id += 1

        owner = Owner(owner_id)
        owner.first_name = personal.name()
        owner.last_name = personal.surname()
        owner.address = address.address()

        yield owner
Пример #3
0
    def seed():
        address = mimesis.Address()
        business = mimesis.Business()
        person = mimesis.Person()

        for _ in range(1, 6):
            distributor = models.Distributor(
                name=business.company(),
                email=person.email(),
                address=address.address(),
                campaign_cost=random.uniform(0, 10),
                max_sales_count=random.uniform(2, 10),
                ow_cost=random.uniform(0, 10),
            )
            db.session.add(distributor)

        db.session.commit()
Пример #4
0
def good_import_generator(n_citizens=20, n_relations=30):
    data = []
    address_generator = mimesis.Address('ru')
    number_generator = mimesis.Numbers()
    person_generator = mimesis.Person('ru')
    gender_generator = mimesis.Person('en')
    datetime_generator = mimesis.Datetime()
    for i in range(1, n_citizens + 1):
        street, building = address_generator.address().rsplit(' ', maxsplit=1)
        gender = gender_generator.gender().lower()
        while gender != 'male' and gender != 'female':
            gender = gender_generator.gender().lower()
        data.append({
            "citizen_id":
            i,
            "town":
            address_generator.city(),
            "street":
            street,
            "building":
            building,
            "apartment":
            number_generator.between(1, 100000),
            "name":
            person_generator.full_name(),
            "birth_date":
            datetime_generator.date(1900, 2018).strftime("%d.%m.%Y"),
            "gender":
            gender,
            "relatives": []
        })
    relations = set()
    for i in range(n_relations):
        relation = (number_generator.between(1, n_citizens),
                    number_generator.between(1, n_citizens))
        while relation in relations or (relation[1], relation[0]) in relations:
            relation = (number_generator.between(1, n_citizens),
                        number_generator.between(1, n_citizens))
        relations.add(relation)

        data[relation[0] - 1]["relatives"].append(relation[1])
        if relation[0] != relation[1]:
            data[relation[1] - 1]["relatives"].append(relation[0])
    return data
Пример #5
0
    def seed():
        address = mimesis.Address()
        business = mimesis.Business()
        person = mimesis.Person()

        vendor_types = [
            {
                "is_supplier": True
            },
            {
                "is_decorator": True
            },
            {
                "is_pick_pack": True
            },
            {
                "is_supplier": True,
                "is_pick_pack": True
            },
            {
                "is_decorator": True,
                "is_pick_pack": True
            },
        ]

        product_types = models.ProductType.query.all()

        # create five vendors for each product type
        for product_type in product_types:
            for vendor_type in vendor_types:
                vendor = models.Vendor(
                    name=f"{address.state()} {business.company()}",
                    email=person.email(),
                    address=address.address(),
                    **vendor_type,
                )

                product_type.vendors.append(vendor)

                db.session.add(vendor)
                db.session.add(product_type)
                db.session.commit()
Пример #6
0
def importToProducer():
    try:
        dsnStr = cx_Oracle.makedsn("217.173.198.135", "1522", "orcltp")
        con = cx_Oracle.connect(user="******", password="******", dsn=dsnStr)
        num = int(input("How many rows should be entered? "))
        last_id = getLastID("producer")
        print("Fetching rows...")
        for x in range(num):
            a = mimesis.Address('en')
            h = mimesis.Hardware('en')
            country = a.country()
            name = h.manufacturer()
            query = "INSERT INTO producer (id_producer, name, country) VALUES  (:1, :2, :3) "
            cursor = con.cursor()
            last_id = last_id + 1
            cursor.execute(query, (last_id, name, country))
            print(query)
            cursor.close()
        con.commit()
        print("Rows added successfully")
    except cx_Oracle.Error as error:
        print("Error occurred:")
        print(error)
    consoleInput()
Пример #7
0
def importToLocation():
    try:
        dsnStr = cx_Oracle.makedsn("217.173.198.135", "1522", "orcltp")
        con = cx_Oracle.connect(user="******", password="******", dsn=dsnStr)
        num = int(input("How many rows should be entered? "))
        last_id = getLastID("location")
        print("Fetching rows...")
        for x in range(num):
            y = mimesis.Address('en')
            city = y.city()
            name = city + ' Office'
            address = y.address() + ', ' + city
            query = "INSERT INTO location (id_location, name, address) VALUES  (:1, :2, :3)"
            cursor = con.cursor()
            last_id = last_id + 1
            cursor.execute(query, (last_id, name, address))
            print(query)
            cursor.close()
        con.commit()
        print("Rows added successfully")
    except cx_Oracle.Error as error:
        print("Error occurred:")
        print(error)
    consoleInput()
Пример #8
0
def address(request):
    return mimesis.Address(request.param)
max_age = config["customers"]["max_age"]
min_age = config["customers"]["min_age"]
joined_start_date = config["customers"]["joined_start_date"]
joined_end_date = config["customers"]["joined_end_date"]
genders = config["genders"][language]
gender_prob = config["genders"]["percentages"]

# data processing config
amounts_cpu = config["data_processing"]["amount_in_cpu"]
auto_batch = True if config["data_processing"][
    "auto_batch_based_in_cpu"] == "True" else False

# loading mocking data type
business = mimesis.Business(language)
person = mimesis.Person(language)
address = mimesis.Address(language)
dates = mimesis.Datetime(language)

# Calculating random probabilities
# 245 countries
country_prob = common_functions.random_probabilities(1, 245)
ages_probab = common_functions.random_probabilities(min_age, max_age)

# Global customers array
customers = []


def generate_customers(amount, index_start):
    # generates customers' info
    # amount: number of customer to generate
    # index_start: from what index starts
Пример #10
0
def generate_picture_name():
    result = ' ' * 26
    while len(result) > 25:
        place = mimesis.Address().country().replace(' ', '_')
        result = re.sub(r'[^A-z0-9]', '', place)
    return result
Пример #11
0
def generate_beacon_name():
    place = mimesis.Address()
    return place.city()
Пример #12
0
def _address():
    return mimesis.Address()
Пример #13
0
import mimesis
from mimesis.builtins import RussiaSpecProvider as Rsp
from mimesis.enums import Gender
import base
import sqlite3
from PIL import ImageTk, Image
import io
import time
import datetime

#заполнение бд

person = mimesis.Person("ru")
rus_person = Rsp()
date = mimesis.Datetime()
adress = mimesis.Address("ru")

for i in range(5):
    gender = person.gender()
    gender_opt = Gender.MALE
    if gender == "Жен.":
        gender_opt = Gender.FEMALE
    person_id = base.get_last_id()
    surname = person.surname(gender=gender_opt)
    name = person.first_name(gender=gender_opt)
    patronymic = rus_person.patronymic(gender=gender_opt)
    birthday = date.date(start=1960, end=2021)
    adr = adress.city() + " " + adress.address()
    phone = person.telephone()
    email = person.email()
    img = image_l.get_avatar()
Пример #14
0
    global surnames_box, labels
    for i in cursor.execute(
            f'SELECT * FROM users WHERE surname = "{surnames_box.get()}"'):
        user = i

    for i in range(len(user)):
        try:
            labels[i]['text'] = user[i]
        except:
            pass


root = Tk()
root.geometry('250x250')
person = mimesis.Person('en')
address = mimesis.Address()
try:
    os.remove('data.db')
except:
    pass

db = sqlite3.connect('data.db')
cursor = db.cursor()

cursor.execute('''CREATE TABLE users (
	id INT,
	surname TEXT,
	name TEXT,
	lastname TEXT,
	age INT,
	birthday INT,
Пример #15
0
def generate_sample_data(total_employees_amount: int, total_patients_amount: int, conn):
    # first - check arguments
    if total_employees_amount < 0 or total_employees_amount % 100.0 != 0.0:
        return 1
    if total_patients_amount < 0 or total_patients_amount % 1000.0 != 0.0:
        return 1

    # mimesis generators will be used because they're really easy. very easy
    # pls read docs on them, it'll take 5 min or even less
    gen_person = mimesis.Person('en')
    date = mimesis.Datetime()
    ssn_id = mimesis.Numbers()
    home_addr = mimesis.Address()
    stuff_jobs = ['janitor', 'cook', 'guard']

    # add multipliers such as no more than 1 Hospital - partially done
    # add loops - partially done

    # Doctors generator. Doctor types have been taken from Wikipedia - all questions for them
    doctor_types = ['Cardiac surgery', 'Cardiothoracic surgery', 'Colorectal surgery', 'Dental surgery',
                    'Organ transplant|Transplant surgery', 'Upper gastrointestinal surgery', 'Vascular surgery',
                    'Craniofacial surgery', 'Neurological surgery', 'Oral and maxillofacial surgery',
                    'Obstetrics and gynaecology', 'Orthopedic surgery', 'Ophthalmology', 'Otorhinolaryngology',
                    'Pediatric surgery', 'Podiatric_surgery', 'Plastic surgery', 'Surgical oncology',
                    'Trauma surgery', 'Thoracic surgery', 'Urology', 'General Surgery']
    for i in range(0, int(0.25 * total_employees_amount), 1):
        r.table('Doctors').insert({
            'doctor_id': i,
            'name': gen_person.full_name(gender=Gender.MALE),
            'date_of_birth': str(date.date(start=1950, end=1995)),
            'sex': 'male',
            'qualification ': doctor_types[randint(0, len(doctor_types) - 1)],
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': 'blue',
            'home_address': home_addr.address(),
            'salary': 12000.00
        }).run(conn)

    # Nurses generator
    for i in range(0, int(0.35 * total_employees_amount), 1):
        r.table('Nurses').insert({
            'nurse_id': i,
            'name': gen_person.full_name(gender=Gender.FEMALE),
            'date_of_birth': str(date.date(start=1950, end=1997)),
            'sex': 'female',
            'qualification': 'nurse',
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'salary': 27000.00
        }).run(conn)

    # Paramedics generator
    for i in range(0, int(0.15 * total_employees_amount), 1):
        r.table('Paramedics').insert({
            'paramedic_id': i,
            'name': gen_person.full_name(gender=Gender.MALE),
            'date_of_birth': str(date.date(start=1980, end=2000)),
            'sex': 'male',
            'qualification': 'ambulance paramedic',
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'salary': 16600.00
        }).run(conn)

    # Administrators generator
    admins_types=['Dean of the Hospital', 'Hospital Administrator', 'Head of Surgeons and Doctors Department',
                  'Head of Nursing Department', 'Head of Emergency Department', 'Head of Recruitment Department',
                  'Head of Medicine Department', 'Head of Equipment Department', 'Head of Security Department',
                  'Medical Student Administration', 'Inventory Head']
    for i in range(0, int(0.15 * total_employees_amount), 1):
        r.table('Administrators').insert({
            'administrator_id': i,
            'name': gen_person.full_name(gender=Gender.FEMALE),
            'date_of_birth': str(date.date(start=1970, end=1990)),
            'sex': 'male',
            'qualification': admins_types[randint(0, len(admins_types) - 1)],
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'salary': 0.00
        }).run(conn)

    # Stuff generator
    for i in range(0, int(0.10 * total_employees_amount), 1):
        r.table('Stuff').insert({
            'stuff_id': i,
            'name': gen_person.full_name(gender=Gender.FEMALE),
            'date_of_birth': str(date.date(start=1950, end=2000)),
            'sex': 'female',
            'vacated_position': stuff_jobs[randint(0, len(stuff_jobs) - 1)],
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'salary': 8800.00
        }).run(conn)

    # Patients generator. Gender division: 0.5 avg
    for i in range(0, int(0.5 * total_patients_amount)):
        r.table('Patients').insert({
            'patient_id': total_employees_amount,
            'name': gen_person.full_name(gender=Gender.FEMALE),
            'date_of_birth': str(date.date(start=1935, end=2015)),
            'sex': 'male',
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'coordinates': {float(randint(10000, 300000) / 100), float(randint(10000, 300000) / 100)},
            'illness_history_head_id': i
        }).run(conn)
    for i in range(int(0.5 * total_patients_amount), int(1.0 * total_patients_amount)):
        r.table('Patients').insert({
            'patient_id': total_employees_amount,
            'name': gen_person.full_name(gender=Gender.FEMALE),
            'date_of_birth': str(date.date(start=1940, end=2015)),
            'sex': 'female',
            'SSN_ID': ssn_id.between(minimum=1000000000000000, maximum=10000000000000000 - 1),
            'telephone': ssn_id.between(minimum=89000000000, maximum=89999999999),
            'home_address': home_addr.address(),
            'coordinates': {float(randint(10000, 300000) / 100), float(randint(10000, 300000) / 100)},
            'illness_history_head_id': i
        }).run(conn)

    # Let's link a little illness histories with their owners.
    # Also, by analogue of extended books, next_ids can be used
    for i in range(int(1.5 * total_employees_amount)):
        r.table('IllnessHistories').insert({
            'history_id': i,
            'owner_id': i,
            'data': {},
            'next_id': ''
        }).run(conn)

    # for this table - maybe generate different types of forms
    r.table('IllnessForms').insert({
        'form_id': total_employees_amount,
        'form_type': '069-uf',
        'doctor_id': total_employees_amount,
        'patient_id': total_employees_amount,
        'procedure_type': 'operation',
        'additional_information': {
            'operation_type': 'bone marrow transplant',
            'result': 'success'
        }
    }).run(conn)

    # Hospital generator
    r.table('Hospital').insert({
        'hospital_id': 0,
        'address': home_addr.address(),
        'coordinates': {0.00, 0.00},
        'director': 'wanted',
        'departments': doctor_types
    }).run(conn)

    # Departments generator
    for i in range(len(doctor_types)):
        r.table('Departments').insert({
            'department_id': i,
            'name': doctor_types[i],
            'leader_id': total_employees_amount,
            'doctors_ids': [total_employees_amount],
            'nurses_ids': [total_employees_amount],
            'administrators_ids': [total_employees_amount],
            'stuff_ids': [total_employees_amount],
            'beds': randint(15, 50)
        }).run(conn)

    # Ambulance generator
    for i in range(int(0.01 * total_employees_amount)):
        r.table('Ambulances').insert({
            'ambulance_id': i,
            'driver_id': 'wanted',
            'doctor_id': 'wanted',
            'paramedic_ids': ['wanted'],
            'coords': {0.00, 0.00}
        }).run(conn)

    return 0
Пример #16
0
# ensure there are 3 input params, second is csv path, third is an integer
if len(sys.argv) != 3 or sys.argv[1][-4:] != '.csv' or not strIsInt(sys.argv[2]):
    print("Please use this program with the following command line parameters:")
    print("python generator.py [csv path] [tuples to generate]")
else:
    full_out = []

    for i in range(int(sys.argv[2])):
        int_out = []
        
        int_out.append(m.Person().username())
        int_out.append(m.Person().name())
        int_out.append(m.Person().last_name())
        int_out.append(m.Person().telephone())
        int_out.append(m.Address().address())
        int_out.append(m.Address().zip_code())
        int_out.append(m.Datetime().date())

        int_out.append(m.Datetime().date())

        int_out.append(m.Hardware().cpu())
        int_out.append(m.Hardware().cpu_frequency())
        int_out.append(m.Hardware().graphics())
        int_out.append(m.Hardware().manufacturer())
        int_out.append(m.Hardware().ram_size())
        int_out.append(m.Hardware().ram_type())
        int_out.append(m.Hardware().resolution())

        int_out.append(m.Games().game())
        int_out.append(m.Datetime().date())