aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--hw.py7
2 files changed, 4 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 2a32ac5..c0cee36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.db
+*.db-journal
*demo*
*test* \ No newline at end of file
diff --git a/hw.py b/hw.py
index ca100c9..aea17d5 100644
--- a/hw.py
+++ b/hw.py
@@ -15,16 +15,14 @@ if chk_1:
cur.execute("CREATE TABLE sexy_tbl (chk INTEGER);")
chk_2 = randint(0,1)
-
cur.execute("INSERT INTO sexy_tbl (chk) VALUES(:chk);", {"chk" : chk_2})
-rst = []
k = []
res = cur.execute("SELECT sum(chk) as sum_chk, count(chk) as count_chk FROM sexy_tbl;")
for desc in cur.description: k.append(desc[0])
-for row in res.fetchall(): rst.append(dict(zip(k,row)))
+row = res.fetchone()
+rcd = dict(zip(k,row))
-rcd = rst[0]
chk_3 = (rcd["sum_chk"]/rcd["count_chk"]) > 0.5
if chk_3:
@@ -36,6 +34,7 @@ diag = input()
if 'sexy' in diag.lower():
print(f"Your sexy score is {rcd['sum_chk']} out of {rcd['count_chk']}.")
+ input()
con.commit()
cur = None