Skip to content
Snippets Groups Projects
Commit 50f89660 authored by Luca2.Colucci@live.uwe.ac.uk's avatar Luca2.Colucci@live.uwe.ac.uk
Browse files

1

parent 6c651c70
No related branches found
No related tags found
No related merge requests found
......@@ -3,33 +3,32 @@ from database import SessionLocal, User, Movie, Showtime, Cinema
# Open a database session
session = SessionLocal()
# Add test users with hashed passwords
admin = User(username="a")
admin.set_password("a")
admin = User(username="admin")
admin.set_password("4321")
admin.role = "admin"
staff = User(username="s")
staff.set_password("s")
staff = User(username="staff")
staff.set_password("1234")
staff.role = "booking_staff"
manager = User(username="m")
manager.set_password("m")
manager = User(username="manager")
manager.set_password("4567")
manager.role = "manager"
session.add_all([admin, staff, manager])
# Add sample cinemas
cinemas = [
Cinema(name="Bristol Horizon", city="Bristol"),
Cinema(name="London Horizon ", city="London"),
Cinema(name="Cardiff Horizon ", city="Cardiff"),
Cinema(name="Birmingham Horizon ", city="Birmingham")
]
session.add_all(cinemas)
# Seed Movies
movies = [
Movie(title="Inception", genre="Sci-Fi", age_rating="PG-13", duration=148, description="A mind-bending thriller."),
Movie(title="The Dark Knight", genre="Action", age_rating="PG-13", duration=152, description="Batman faces the Joker."),
Movie(title="Interstellar", genre="Sci-Fi", age_rating="PG-13", duration=169, description="A journey beyond the stars."),
Movie(title="Titanic", genre="Romance", age_rating="PG-13", duration=195, description="A love story on the doomed ship."),
Movie(title="The Godfather", genre="Crime", age_rating="R", duration=175, description="The story of a powerful mafia family."),
Movie(title="Inception", genre="Sci-Fi", age_rating="12A", duration=148, description="A mind-bending thriller."),
Movie(title="The Dark Knight", genre="Action", age_rating="12A", duration=152, description="Batman faces the Joker."),
Movie(title="Interstellar", genre="Sci-Fi", age_rating="12A", duration=169, description="A journey beyond the stars."),
Movie(title="Titanic", genre="Romance", age_rating="12A", duration=195, description="A love story on the doomed ship."),
Movie(title="The Godfather", genre="Crime", age_rating="18", duration=175, description="The story of a powerful mafia family."),
]
session.add_all(movies)
......@@ -39,14 +38,12 @@ movies = session.query(Movie).all()
showtimes = [
Showtime(movie_id=movies[0].movie_id, cinema_id=cinemas[0].cinema_id, screen_number=2, show_date="2025-04-05", show_time="19:00", available_seats=100),
Showtime(movie_id=movies[1].movie_id, cinema_id=cinemas[1].cinema_id, screen_number=1, show_date="2025-04-05", show_time="18:30", available_seats=120),
Showtime(movie_id=movies[2].movie_id, cinema_id=cinemas[0].cinema_id, screen_number=3, show_date="2025-05-22", show_time="20:00", available_seats=80),
Showtime(movie_id=movies[3].movie_id, cinema_id=cinemas[0].cinema_id, screen_number=3, show_date="2025-03-30", show_time="20:00", available_seats=80)
Showtime(movie_id=movies[2].movie_id, cinema_id=cinemas[0].cinema_id, screen_number=3, show_date="2025-04-09", show_time="20:00", available_seats=80),
Showtime(movie_id=movies[3].movie_id, cinema_id=cinemas[0].cinema_id, screen_number=3, show_date="2025-05-20", show_time="20:00", available_seats=80)
]
session.add_all(showtimes)
session.commit()
print("🚨 Sample data added successfully!")
print("Data added successfully!")
session.close()
# python database/seed.py
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment