user5 = User(username='******', password="******") user6 = User(username='******', password="******") user7 = User(username='******', password="******") admin = User(username='******', password="******") john.isAdmin = False info_john = UserInfo(name="Jhon", surname="Doe", date_of_birth="01/09/1985", api_key="klaSKJDOA83847JSDskdjajeb39",user="******") info_user1 = UserInfo(name="Marc", surname="Zucker", date_of_birth="01/09/1985", api_key="klajd;aihd9[0jdioha",user="******") info_user2 = UserInfo(name="Fred", surname="List", date_of_birth="01/08/1983", api_key="asdkjasd8pu322d8h32d8h2iN",user="******") info_user3 = UserInfo(name="Jack", surname="Balmore", date_of_birth="01/09/1965", api_key="PGHJOUKJOK9059069J5J",user="******") info_user4 = UserInfo(name="Laura", surname="Fresca", date_of_birth="09/09/1976", api_key="KADSNDCAISDJASIOMAJSIDAJ",user="******") info_user5 = UserInfo(name="Marta", surname="London", date_of_birth="22/04/1985", api_key="XCVBCXVBVCXZCVBCX",user="******") info_user6 = UserInfo(name="Marika", surname="Kovac", date_of_birth="17/10/1985", api_key="93274146147Y3EUDSBHH",user="******") info_user7 = UserInfo(name="Alessia", surname="Panatta", date_of_birth="10/09/1988", api_key="974YD7ASDAS9DAG79TSAD",user="******") info_admin = UserInfo(name="Mika", surname="Hakkinen", date_of_birth="01/09/1982", api_key="AS7RA968GDBVDQIYILDSY7",user="******") post = Post() post.title = "Hello World" post.body = "This is the first post of jhon" post.author = john db.session.add(post) db.session.add(john) db.session.add(user1) db.session.add(user2) db.session.add(user3) db.session.add(user4) db.session.add(user5) db.session.add(user6) db.session.add(user7) db.session.add(admin) db.session.add(info_john) db.session.add(info_user1) db.session.add(info_user2)
from app import db, User, Post db.create_all() john = User(username='******') post = Post() post.title = "Hello World" post.body = "This is the first post of jhon" post.author = john db.session.add(post) db.session.add(john) jim = User(username='******') db.session.add(jim) post2 = Post() post2.title = "Woooow" post2.body = "I'm the maaaaask" post2.author = jim db.session.add(post2) db.session.commit() print(User.query.all()) print(Post.query.all())
from app import db, User, Post db.create_all() # create tables from models user1 = User(name="Sadhan Sarker", email='*****@*****.**') post1 = Post() post1.title = "Blog Post Title 1" post1.body = "This is the first blog post 1" post1.author = user1 db.session.add(post1) db.session.add(user1) db.session.commit() print(User.query.all()) print(Post.query.all())