-
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
commit #945
base: master
Are you sure you want to change the base?
commit #945
Changes from 9 commits
bf5a94c
823ec89
665478b
a7555e8
22634f9
1b16e12
ef60338
e9d5ce8
74050b4
a23a4d5
c87dfa1
8fbb3a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you didn't have to delete this file - just needed to revert changes that you did. Make it look like the file on master and that's it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert changes to main.py - it should look exactly like on master branch |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import sqlite3 | ||
|
||
from models import Actor | ||
|
||
|
||
class ActorManager: | ||
def __init__(self) -> None: | ||
self._connection = sqlite3.connect("cinema.db") | ||
self.create_table() | ||
self.table_name = "actors" | ||
|
||
def create_table(self) -> None: | ||
self._connection.execute( | ||
""" | ||
CREATE TABLE IF NOT EXISTS actors ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bad sql formatting. You can use this to make it pretty https://sqlformat.org/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually here you can keep as is - sql formatter will spread lines too much. But check other queries - the least you can do is to put each keyword on new line - thats the standard |
||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
first_name TEXT NOT NULL, | ||
last_name TEXT NOT NULL | ||
) | ||
""" | ||
) | ||
self._connection.commit() | ||
|
||
def create(self, first_name: str, last_name: str) -> None: | ||
self._connection.execute( | ||
f""" | ||
INSERT INTO {self.table_name} | ||
(first_name, last_name) VALUES (?, ?) | ||
""", | ||
(first_name, last_name) | ||
) | ||
self._connection.commit() | ||
|
||
def all(self) -> list: | ||
cinema_cursor = self._connection.execute( | ||
"SELECT * FROM actors" | ||
) | ||
return [ | ||
Actor(*row) for row in cinema_cursor | ||
] | ||
|
||
def update( | ||
self, | ||
id_: int, | ||
new_first_name: str, | ||
new_last_name: str | ||
) -> None: | ||
self._connection.execute( | ||
f""" | ||
UPDATE {self.table_name} | ||
SET first_name = ?, last_name = ? | ||
WHERE id = ?""", | ||
(new_first_name, new_last_name, id_) | ||
) | ||
self._connection.commit() | ||
|
||
def delete(self, id_delete: int) -> None: | ||
self._connection.execute( | ||
f""" | ||
DELETE FROM {self.table_name} | ||
WHERE id = ? | ||
""", | ||
(id_delete,) | ||
) | ||
self._connection.commit() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Actor: | ||
id: int | ||
first_name: str | ||
last_name: str |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove database 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.
remove database file