-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.py
27 lines (21 loc) · 793 Bytes
/
seed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from app import app
from models import User, db
def seed_database():
# Clear existing data
db.drop_all()
db.create_all()
# Create test users
user1 = User(username="testuser1", email="[email protected]", password="password1")
user2 = User(username="testuser2", email="[email protected]", password="password2")
user3 = User(username="testuser3", email="[email protected]", password="password3")
# Add test users to the session
db.session.add(user1)
db.session.add(user2)
db.session.add(user3)
# Commit the session
db.session.commit()
# Print a message to indicate the seeding process is complete
print("Database seeded with test users.")
if __name__ == "__main__":
with app.app_context():
seed_database()