Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sorting_database_records
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Brady James Garvin
sorting_database_records
Commits
140896e4
Commit
140896e4
authored
6 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Adapted code to support example functionality from class.
parent
8f9f5d59
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+3
-3
3 additions, 3 deletions
main.py
movies_installer.py
+5
-44
5 additions, 44 deletions
movies_installer.py
with
8 additions
and
47 deletions
main.py
+
3
−
3
View file @
140896e4
from
sys
import
stderr
from
sys
import
stderr
from
sqlalchemy.exc
import
SQLAlchemyError
from
sqlalchemy.exc
import
SQLAlchemyError
from
movies
import
MovieDatabase
,
Genr
e
from
movies
import
MovieDatabase
,
Movi
e
from
kivy.app
import
App
from
kivy.app
import
App
...
@@ -14,8 +14,8 @@ class MoviesApp(App):
...
@@ -14,8 +14,8 @@ class MoviesApp(App):
self
.
session
=
self
.
movie_database
.
create_session
()
self
.
session
=
self
.
movie_database
.
create_session
()
def
print_records
(
self
):
def
print_records
(
self
):
for
genr
e
in
self
.
session
.
query
(
Genr
e
):
for
movi
e
in
self
.
session
.
query
(
Movi
e
):
print
(
genre
.
name
)
print
(
f
'
{
movie
.
title
}{
"
"
*
(
12
-
len
(
movie
.
title
))
}
(budget $
{
movie
.
budget
}
, gross revenue $
{
movie
.
gross_revenue
}
)
'
)
def
main
():
def
main
():
...
...
This diff is collapsed.
Click to expand it.
movies_installer.py
+
5
−
44
View file @
140896e4
...
@@ -4,53 +4,14 @@ from datetime import date
...
@@ -4,53 +4,14 @@ from datetime import date
from
sqlalchemy.exc
import
SQLAlchemyError
from
sqlalchemy.exc
import
SQLAlchemyError
from
movies
import
MovieDatabase
,
Movie
,
Genre
,
Review
from
movies
import
MovieDatabase
,
Movie
def
add_starter_data
(
session
):
def
add_starter_data
(
session
):
biography
=
Genre
(
name
=
'
Biography
'
)
session
.
add
(
Movie
(
title
=
'
Example I
'
,
budget
=
1000
,
gross_revenue
=
2000
))
drama
=
Genre
(
name
=
'
Drama
'
)
session
.
add
(
Movie
(
title
=
'
Example II
'
,
budget
=
2000
,
gross_revenue
=
2000
))
history
=
Genre
(
name
=
'
History
'
)
session
.
add
(
Movie
(
title
=
'
Example III
'
,
budget
=
2000
,
gross_revenue
=
1000
))
action
=
Genre
(
name
=
'
Action
'
)
session
.
add
(
Movie
(
title
=
'
Example IV
'
,
budget
=
1000
,
gross_revenue
=
1000
))
adventure
=
Genre
(
name
=
'
Adventure
'
)
sci_fi
=
Genre
(
name
=
'
SciFi
'
)
session
.
add
(
biography
)
session
.
add
(
drama
)
session
.
add
(
history
)
session
.
add
(
action
)
session
.
add
(
adventure
)
session
.
add
(
sci_fi
)
# Hidden Figures (Biography, Drama, History)
# 2016 October 15
# Budget: $25,000,000
# Gross Revenue: $206,000,000
# Sample review from IMDB:
# "★★★★★★★★★☆ In the opinion of this reviewer, an extraordinary achievement."
hidden_figures
=
Movie
(
title
=
'
Hidden Figures
'
,
budget
=
25000000
,
gross_revenue
=
206000000
,
opening_date
=
date
(
2016
,
10
,
15
),
genres
=
[
biography
,
drama
,
history
])
session
.
add
(
hidden_figures
)
extraordinary_achievement
=
Review
(
movie
=
hidden_figures
,
score
=
9
,
comments
=
'
In the opinion of this reviewer, an extraordinary achievement.
'
)
session
.
add
(
extraordinary_achievement
)
# Avengers: Infinity War (Action, Adventure)
# 2018 April 27
# Budget: $300,000,000
# Gross Revenue: $2,048,000,000
# Sample reviews from IMDB:
# "★★★★★★★★★★ A summer film that IS even better than the hype."
# "★★★★★★☆☆☆☆ Bordering on a comedy, "Infinity War" is overhyped, lacked direction, but at times impressed."
infinity_war
=
Movie
(
title
=
'
Avengers: Infinity War
'
,
budget
=
300000000
,
gross_revenue
=
2048000000
,
opening_date
=
date
(
2018
,
4
,
27
),
genres
=
[
action
,
adventure
])
session
.
add
(
infinity_war
)
better_than_hype
=
Review
(
movie
=
infinity_war
,
score
=
10
,
comments
=
'
A summer film that IS even better than the hype.
'
)
bordering_on_comedy
=
Review
(
movie
=
infinity_war
,
score
=
6
,
comments
=
'
Bordering on a comedy,
"
Infinity War
"
is overhyped, lacked direction, but
'
'
at times impressed.
'
)
session
.
add
(
better_than_hype
)
session
.
add
(
bordering_on_comedy
)
def
main
():
def
main
():
...
...
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