Beispiel #1
0
 def tearDown(self):
     """
     测试运行之后
     数据库和应用上下文在 tearDown() 方法中删除
     :return:
     """
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Beispiel #2
0
def init_data():
    from fake import users, posts, comments, follows
    from flasky import db
    db.drop_all()
    db.create_all()
    users()
    posts()
    comments()
    # follows()
    return 'data init successfully'
Beispiel #3
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Beispiel #4
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Beispiel #5
0
def dropdb():
    if prompt_bool('Drop all data?'):
        db.drop_all()
        print('Dropped database')
Beispiel #6
0
from flasky.Models import User, Post
from flasky import db, app

db.drop_all()
db.create_all()
user1 = User(username="******", email="*****@*****.**", password="******")
db.session.add(user1)
user2 = User(username="******", email="*****@*****.**", password="******")
db.session.add(user2)
post1 = Post(title="first post", content=" the content", user_id=1)
db.session.add(post1)
db.session.commit()
#

app.run(host="0.0.0.0", port=5000, debug=True)

# print(User.query.all())
# print(Post.query.all())
Beispiel #7
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()  #removes all the table after every test.