From 4ada02f510df07816792576c6343203519099ad4 Mon Sep 17 00:00:00 2001 From: jonnybravo Date: Mon, 7 Aug 2023 21:28:57 +0200 Subject: [PATCH] commit message from python script --- my_movies/database.py | 24 +++++++++++++++++++++++- my_movies/spam.db | Bin 8192 -> 8192 bytes 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/my_movies/database.py b/my_movies/database.py index 2ecb461..ee2813f 100644 --- a/my_movies/database.py +++ b/my_movies/database.py @@ -14,10 +14,32 @@ class db_work: ''' cursor.execute(sql_code) con_db.commit() + + def add_value_db(self, cooler_typ = str, glueckszahl = int): + with sqlite3.connect(self.db_file) as con_db: + cursor = con_db.cursor() + sql_code = ''' + INSERT INTO eggs (cooler_typ, glückszahl) + VALUES('{coolertype}', {eine_zahl}); + '''.format(coolertype=cooler_typ,eine_zahl=glueckszahl) + cursor.execute(sql_code) + con_db.commit() + + def show_value(self): + with sqlite3.connect(self.db_file) as con_db: + cursor = con_db.cursor() + sql_code = ''' + SELECT * FROM eggs; + ''' + cursor.execute(sql_code) + ergebnis = cursor.fetchall() + return ergebnis if __name__ == "__main__": script_folder = os.path.dirname(os.path.realpath(__file__)) db_file_full = script_folder + os.sep + "spam.db" my_db = db_work(db_file=db_file_full) - my_db.create_db() \ No newline at end of file + my_db.create_db() + my_db.add_value_db(cooler_typ="daniel-2", glueckszahl=42) + print(my_db.show_value()) \ No newline at end of file diff --git a/my_movies/spam.db b/my_movies/spam.db index c4fe583c9c19476bbf8ece1939761ddabc899f29..f92ff5f90c66529733914edd3cb835fa8eaa092f 100644 GIT binary patch delta 58 zcmZp0XmFSy&B#1a#+i|MW5N=C4krF*4E$gCpKTTtxWzBU!^AAhn39;6nVO?(q{YR^ JED7al0RY@v51Ie~ delta 28 kcmZp0XmFSy&B!=W#+i|EW5N=CCI*4cf&y3hCpM@80C8*w