From 0cb8bd29c033413bfdc4ad81812515eaaa278417 Mon Sep 17 00:00:00 2001 From: SS Huh Date: Wed, 8 Dec 2021 20:19:52 +0900 Subject: [PATCH] Add files via upload --- challenges139-145/BookInfo.db | Bin 0 -> 16384 bytes challenges139-145/challenge-143_.py | 15 +++++++++ challenges139-145/challenge-144_.py | 23 ++++++++++++++ challenges139-145/challenge-145_.py | 46 ++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 challenges139-145/BookInfo.db create mode 100644 challenges139-145/challenge-143_.py create mode 100644 challenges139-145/challenge-144_.py create mode 100644 challenges139-145/challenge-145_.py diff --git a/challenges139-145/BookInfo.db b/challenges139-145/BookInfo.db new file mode 100644 index 0000000000000000000000000000000000000000..f25aa2db0f7f08321c815a5e11ceb68854acc046 GIT binary patch literal 16384 zcmeI&&rTCT7y$6u-7W=$4x-YKs+ojf!2$^yFLH6AjUphmHZjB~nRch`gzXNUog(!{ zJb5v`0T*Avi*KNb_y8sb4j%Q)(do9;7NRF(H2Egk?(F>i=69Q!KDfWi6(c1ft5lKe zXapGsx=XjDHD{dAJ4Gu_`tr{Xv7Q8c&mY8W3QD|Uo1$M5tD5(t0*2!H?xfB*=9 z00@8p2!H?x{CR;r+lt2Habu4wTJYGS5L-d`6Ise-oP37loyFA*35%u%iB8LD!hOZc zOp@G=D#j^E+$Ab!UJ3~!BF{1HA!q__( zhSBO3v|naVDDA>lF!yM+HC=BkS&tT(C@pfSD&gGIvu0o1Nf?OxF53-ip5E1O(z+7i z_hx&{&G~l5($M`)>|y;x@IJy{@CW=xXCQ$92!H?xfB*=900@8p2!H?xfB*>mZGrO< zYhrvoC{jrta?fSy=DC7DW?7SoyK^fuBqyHg@A9JLffC-BX(h*(Sdn?05~sqX-)cW@ zSgC|lrm8~8Ql;6Jv%HYCI&BQ<6-Dq{gumiX_`S|R0s#;J0T2KI5C8!X009sH0T2KI z5cr1#ur*_P8_g%pe1(w)(|5|8RGA_TQUAG5 zl+2HQo;_oug;dxsU^~nwE~j2Vs*OM~**LL? ORDER BY DatePublished""", [selectionyear]) + +for x in cursor.fetchall(): + print(x) + +db.close() \ No newline at end of file diff --git a/challenges139-145/challenge-144_.py b/challenges139-145/challenge-144_.py new file mode 100644 index 0000000..69c0043 --- /dev/null +++ b/challenges139-145/challenge-144_.py @@ -0,0 +1,23 @@ +import sqlite3 + +file = open("Booklist.txt","w") + +with sqlite3.connect("BookInfo.db") as db: + cursor=db.cursor() + +cursor.execute("SELECT Name from Authors") +for x in cursor.fetchall(): + print(x) + +print() +selectauthor=input("Enter an author's name: ") +print() + +cursor.execute("SELECT * from Books WHERE Author=?", [selectauthor]) +for x in cursor.fetchall(): + newrecord=str(x[0])+" - "+x[1]+" - "+x[2]+" - "+str(x[3])+"\n" + file.write(newrecord) + +file.close() + +db.close() \ No newline at end of file diff --git a/challenges139-145/challenge-145_.py b/challenges139-145/challenge-145_.py new file mode 100644 index 0000000..fab2033 --- /dev/null +++ b/challenges139-145/challenge-145_.py @@ -0,0 +1,46 @@ +import sqlite3 +from tkinter import * + +def addtolist(): + newname=sname.get + newgrade=sgrade.get + cursor.execute("INSERT INTO Scores (name,score) VALUES (?,?)", (newname,newgrade)) + db.commit() + sname.delete(0,END) + sgrade.delete(0,END) + sname.focus() + +def clearlist(): + sname.delete(0,END) + sgrade.delete(0,END) + sname.focus() + +with sqlite3.connect("TestScore.db") as db: + cursor=db.cursor() + +cursor.execute("""CREATE TABLE IF NOT EXISTS Scores( + id integer RIMAY KEY, name text, score integer);""") + +window=Tk() +window.title("TestScores") +window.geometry("450x200") + +label1=Label(text="Enter student's name: ") +label1.place(x=30, y=35) +sname=Entry(text="") +sname.place(x=150, y=35, width=200, height=25) +sname.focus() + +label2=Label(text="Enter student's grade: ") +label2.place(x=30, y=80) +sgrade=Entry(text="") +sgrade.place(x=150, y=80, width=200, height=25) +sgrade.focus() + +addbtn=Button(text="Add", command=addtolist) +addbtn.place(x=150, y=120, width=75, height=25) +clearbtn=Button(text="Clear", command=clearlist) +clearbtn.place(x=250, y=120, width=75, height=25) + +window.mainloop() +db.close \ No newline at end of file