diff --git a/my_movies/database.py b/my_movies/database.py index bb7c41e..49066b4 100644 --- a/my_movies/database.py +++ b/my_movies/database.py @@ -9,8 +9,8 @@ class db_work: cursor = con_db.cursor() sql_code = """ CREATE TABLE IF NOT EXISTS movies( - 'id' INTEGER AUTOINCREMENT, - 'name' TEXT PRIMARY KEY, + 'id' INTEGER PRIMARY KEY AUTOINCREMENT, + 'name' TEXT, 'filmgenres' TEXT, 'year' TEXT, 'persönlich' TEXT @@ -40,13 +40,22 @@ class db_work: cursor.execute(sql) if not cursor.fetchone(): print("Film wird angelgt ") - #self.speicher_aktion(name, ort, vorfall) + self.speicher_aktion(movie=name, filmgenre=movie_genre, year=movie_year, persönlich=per_info) else: print("Film bereits vorhanden !") print("Eingabevorgang wurde beendet.") - def speicher_aktion(): - pass + def speicher_aktion(self, movie = str, filmgenre = str, year = str, persönlich = str): + with sqlite3.connect(self.db_file) as verbindung: + cursor = verbindung.cursor() + sql = """INSERT INTO movies(name, filmgenres, year, 'persönlich' ) + VALUES ( '{movie}', '{filmgenre}', '{year}', '{persönlich}' );""".format( + movie=movie, + filmgenre=filmgenre, + year=year, + persönlich=persönlich) + + cursor.execute(sql) def show_value(self, sql_query = str): with sqlite3.connect(self.db_file) as con_db: diff --git a/my_movies/my_moviedb.db b/my_movies/my_moviedb.db index e69de29..4e3b4ca 100644 Binary files a/my_movies/my_moviedb.db and b/my_movies/my_moviedb.db differ