def register(name, email, pwd): pwd_hash = bcrypt.generate_password_hash(pwd) customer = models.Customer(name, email, pwd_hash) db.session.add(customer) db.session.commit()
#!env/bin/python from melonhub import db, bcrypt from melonhub.models import Customer from datetime import datetime print("==========") print("This script adds a customer") print("==========") name = input("Name: ") email = input("Email: ") pwd = input("Password: "******"Country: ") customer.address = input("Address: ") customer.zip = input("Zip: ") customer.city = input("City: ") customer.gender = input("Gender: ") year = int(input("Birth year: ")) month = int(input("Birth month (e.g. 5 for May): ")) day = int(input("Birth day: ")) customer.birthdate = datetime(year, month, day) db.session.add(customer) db.session.commit() customers = Customer.query.all()