Exemplo n.º 1
0
def main():
    mysql_config = {
        "host": "127.0.0.1",
        "port": 33060,
        "user": "******",
        "password": "******"
    }

    g = Generic('ru')
    p = g.personal
    a = g.address
    date = datetime.today().strftime("%b %d %Y %H:%M")

    session = mysqlx.get_session(mysql_config)

    if False:
        for i in range(12, 14):
            name = p.full_name()

            query = "Insert into garage.user values({4},{0},\"{1}\",\"{2}\",\"{3}\")".format(
                1, p.username(), p.password(), name, i)
            session.sql(query).execute()

            print(query)
            query = "Insert into garage.driver values(\"{0}\",{1},{2},{3},{4})".format(
                name,
                p.age(),
                Random().randint(1, 10),
                Random().randint(10000, 30000),
                i,
            )
            print(query)

        session.sql(query).execute()
    rnd = Random()

    for i in range(151):
        try:
            start = a.address()
            finish = a.address()
            plane = 'не оговорен'
            success = rnd.randint(0, 1)
            client = p.full_name()
            id_avto = rnd.choice([1, 2, 3])
            id_driver = rnd.choice([1, 2] + [i for i in range(6, 14)])
            id = i

            query = 'Insert into garage.route values("{0}","{1}","{2}",{3},"{4}",{5},{6},{7})'.format(
                start, finish, plane, success, client, id_avto, id_driver, id)
            session.sql(query).execute()
            print(query)
        except Exception:
            continue

    session.close()
Exemplo n.º 2
0
    def init(count=2000, locale='en'):
        from elizabeth import Generic, Text
        from random import randint, choice
        gen = Generic(locale)
        text = Text(locale)

        for _ in range(count):
            gen_post = Post(author=choice(User.objects.all()),
                            text=text.text(5),
                            likes=randint(0, 100))
            gen_post.save()
Exemplo n.º 3
0
 def _bootstrap(count=300, gender='male'):
     from elizabeth import Generic
     g = Generic('en')
     for _ in range(count):
         user = User(full_name=g.personal.full_name(gender),
                     age=g.personal.age(),
                     birth=g.datetime.date(start=1980,
                                           end=2000,
                                           fmt='%Y-%m-%d'),
                     email=g.personal.email(),
                     ipv4=g.network.ip_v4(),
                     phone=g.personal.telephone(),
                     street=g.address.street_name(),
                     city=g.address.city())
         user.save()
Exemplo n.º 4
0
 def setUp(self):
     self.generic = Generic(self.LANG)
Exemplo n.º 5
0
    'Единовременная выплата в связи с ТЖС',
    'Пособие по уходу за ребенком до 3-х лет',
    'Ежемесячная выплата многодетнам семьям', 'Льгота на оплату ЖП и ЖКУ',
    'Пособие по нуждаемости',
    'Компенсания в связи с проживанием на загрязненной территории',
    'Единовременная выплаты к праздничным датам')
pp = pprint.PrettyPrinter(indent=4)

# Кол-во выплат у каждого
payments = 10
# В скольких районах он будет стоять на учете
r = 2
# Соль
soul = 'Соцзащита1864io72grFG'
# Настройка генератора на Елизабет
g = Generic('ru')
user = Personal('ru')
pols = ('male', 'female')

# Соединение с БД
client = MongoClient('192.168.0.195', 27017)
db = client['1019']
collection = db['payments']
# Кол-во упаковок
packs = 300
pack_count = 0

while pack_count < packs:
    pack_count += 1
    start = time.time()
    people_for_download = dict()