Add files via upload

This commit is contained in:
SS Huh 2021-12-08 20:19:52 +09:00 committed by GitHub
parent fcd4cfa8bc
commit 0cb8bd29c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 0 deletions

Binary file not shown.

View 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()

View 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()

View 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