Add files via upload
This commit is contained in:
parent
fcd4cfa8bc
commit
0cb8bd29c0
BIN
challenges139-145/BookInfo.db
Normal file
BIN
challenges139-145/BookInfo.db
Normal file
Binary file not shown.
15
challenges139-145/challenge-143_.py
Normal file
15
challenges139-145/challenge-143_.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
with sqlite3.connect("BookInfo.db") as db:
|
||||||
|
cursor=db.cursor()
|
||||||
|
|
||||||
|
selectionyear=int(input("Enter a year: "))
|
||||||
|
print()
|
||||||
|
|
||||||
|
cursor.execute("""SELECT Books.Title, Books.DatePublished, Books.Author
|
||||||
|
FROM Books WHERE DatePublished >? ORDER BY DatePublished""", [selectionyear])
|
||||||
|
|
||||||
|
for x in cursor.fetchall():
|
||||||
|
print(x)
|
||||||
|
|
||||||
|
db.close()
|
23
challenges139-145/challenge-144_.py
Normal file
23
challenges139-145/challenge-144_.py
Normal file
@ -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()
|
46
challenges139-145/challenge-145_.py
Normal file
46
challenges139-145/challenge-145_.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user