-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #958
base: master
Are you sure you want to change the base?
Solution #958
Conversation
app/main.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't commit nothing to main file
app/cinema.sqlite
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete DB from your PR
app/managers.py
Outdated
|
||
def create(self, first_name: str, last_name: str) -> None: | ||
self._connection.execute( | ||
f"INSERT INTO {self.table_name} VALUES (?, ?, ?) ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use parametrization, here you now clear which fields you need to insert
app/managers.py
Outdated
f"UPDATE {self.table_name} " | ||
f"SET first_name=?, last_name =? " | ||
f"WHERE id=? ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use triple quotes
app/managers.py
Outdated
f"UPDATE {self.table_name} " | ||
f"SET first_name=?, last_name =? " | ||
f"WHERE id=? ", | ||
(f_name, l_name, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are bad variable names
app/managers.py
Outdated
) | ||
self._connection.commit() | ||
|
||
def all(self) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functio will return list of what? Fix annotation
app/managers.py
Outdated
f"DELETE FROM {self.table_name} " | ||
f"WHERE id=? ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use triple quotes
app/managers.py
Outdated
self._connection.execute( | ||
f"DELETE FROM {self.table_name} " | ||
f"WHERE id=? ", | ||
(key,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not key, but id)
You can put id_
app/main.py
Outdated
@@ -11,3 +11,4 @@ | |||
# print(Actor.objects.all()) | |||
# Actor.objects.delete(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert changes to this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not done - make sure this file look exactly like on master
app/managers.py
Outdated
@@ -0,0 +1,44 @@ | |||
import sqlite3 | |||
from models import Actor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be a blank line between different kinds of imports + we use full path from app
app/managers.py
Outdated
def __init__(self) -> None: | ||
self._connection = sqlite3.connect("./cinema.sqlite") | ||
self.table_name = "actors" | ||
self.db_name = "cinema.sqlite" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you create this attribute and never use it?
app/managers.py
Outdated
def create(self, first_name: str, last_name: str) -> None: | ||
self._connection.execute( | ||
f""" | ||
INSERT INTO {self.table_name} (first_name, last_name) VALUES (?, ?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check sql formatting - each key word must start from a new line. Use this tool to help you with styling https://sqlformat.org/
app/main.py
Outdated
@@ -11,3 +11,4 @@ | |||
# print(Actor.objects.all()) | |||
# Actor.objects.delete(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not done - make sure this file look exactly like on master
app/managers.py
Outdated
f""" | ||
INSERT INTO {self.table_name} (first_name, last_name) | ||
VALUES (?, ?) | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to move it just 4 spaces to the left :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job!
Its work XD