Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HC Booking System 2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca2.Colucci@live.uwe.ac.uk
HC Booking System 2
Commits
50f89660
Commit
50f89660
authored
2 months ago
by
Luca2.Colucci@live.uwe.ac.uk
Browse files
Options
Downloads
Patches
Plain Diff
1
parent
6c651c70
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
database/seed.py
+17
-20
17 additions, 20 deletions
database/seed.py
with
17 additions
and
20 deletions
database/seed.py
+
17
−
20
View file @
50f89660
...
...
@@ -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
=
"
s
taff
"
)
staff
.
set_password
(
"
1234
"
)
staff
.
role
=
"
booking_staff
"
manager
=
User
(
username
=
"
m
"
)
manager
.
set_password
(
"
m
"
)
manager
=
User
(
username
=
"
m
anager
"
)
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-0
5-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-0
3-3
0
"
,
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-0
4-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-0
5-2
0
"
,
show_time
=
"
20:00
"
,
available_seats
=
80
)
]
session
.
add_all
(
showtimes
)
session
.
commit
()
print
(
"
🚨 Sample d
ata added successfully!
"
)
print
(
"
D
ata added successfully!
"
)
session
.
close
()
# python database/seed.py
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment