create-db.py (794B)
1 from random import randint, choice 2 from server.app import db, bcrypt 3 from server.models import User 4 5 TOKEN_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz' 6 7 users = [ 8 # (1, False, 'Boer Herman', '[email protected]', 2), 9 # (2, True, 'Administrator Ralf', '[email protected]', None), 10 ] 11 12 address = 'Kerklaan 69\n9876XY Groningen' 13 14 hashed_password = bcrypt.generate_password_hash('hallo').decode('utf-8') 15 16 db.create_all() 17 18 for 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 32 db.session.commit() 33 print('Added')