hanze/muizenval

create-db.py in master
Repositories | Summary | Log | Files

create-db.py (794B) download


 1from random import randint, choice
 2from server.app import db, bcrypt
 3from server.models import User
 4
 5TOKEN_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
 6
 7users = [
 8    #    (1, False, 'Boer Herman', '[email protected]', 2),
 9    #   (2, True, 'Administrator Ralf', '[email protected]', None),
10]
11
12address = 'Kerklaan 69\n9876XY Groningen'
13
14hashed_password = bcrypt.generate_password_hash('hallo').decode('utf-8')
15
16db.create_all()
17
18for id, admin, name, email, contact in users:
19    phone = '06-' + str(randint(10000000, 99999999))
20    user = User(
21        id=id,
22        admin=admin,
23        name=name,
24        email=email,
25        password=hashed_password,
26        phone=phone,
27        address=address,
28        contact=contact
29    )
30    db.session.add(user)
31
32db.session.commit()
33print('Added')