commit message from python script
This commit is contained in:
@@ -24,14 +24,15 @@ class db_work:
|
||||
cursor = con_db.cursor()
|
||||
fd = open(self.script_folder + os.sep + "add_value.sql", "r")
|
||||
sql_code = fd.read().format(coolertype=cooler_typ,eine_zahl=glueckszahl)
|
||||
#sql_code = '''
|
||||
# INSERT INTO eggs (cooler_typ, glückszahl)
|
||||
# VALUES('{coolertype}', {eine_zahl});
|
||||
# '''.format(coolertype=cooler_typ,eine_zahl=glueckszahl)
|
||||
|
||||
cursor.execute(sql_code)
|
||||
|
||||
try:
|
||||
cursor.execute(sql_code)
|
||||
except sqlite3.IntegrityError:
|
||||
return False
|
||||
|
||||
con_db.commit()
|
||||
|
||||
return True
|
||||
|
||||
def show_value(self):
|
||||
with sqlite3.connect(self.db_file) as con_db:
|
||||
cursor = con_db.cursor()
|
||||
@@ -48,5 +49,6 @@ if __name__ == "__main__":
|
||||
db_file_full = script_folder + os.sep + "spam.db"
|
||||
my_db = db_work(db_file=db_file_full)
|
||||
my_db.create_db()
|
||||
my_db.add_value_db(cooler_typ="daniel-3", glueckszahl=42)
|
||||
add_value_to_db = my_db.add_value_db(cooler_typ="daniel-5", glueckszahl=42)
|
||||
print (add_value_to_db)
|
||||
print(my_db.show_value())
|
||||
Reference in New Issue
Block a user