from os import truncate
import sqlite3
class okul:
def __init__(self,name,country):
self.name = name
self.country = country
self.status = True
self.connectDataBase()
def run(self):
self.menu()
self.status = False
choice = self.choice()
if choice == 1:
self.veriekleme()
if choice == 2:
self.verisilme()
if choice == 3:
self.verigüncelleme()
if choice == 4:
self.yazdır()
if choice == 5:
self.cıkıs()
def menu(self):
print("****** {} Admin System ******".format(self.name))
print("1-Veri Ekleme\n2-Veri Silme\n3-Veri Güncelleme\n4-Tüm Verileri Yazdır\n5-Çıkış")
def choice(self):
while True:
try:
process = int(input("Seçenek Giriniz: "))
if process < 1 or process > 5:
print("Lütfen Geçerli Bir Sayı Giriniz!")
continue
break
except ValueError:
print("Lütfen Bir Sayı Giriniz!")
return process
def veriekleme(self):
print("****** Veri Ekleme ******")
isim = input("Veri İsmi: ").lower().capitalize()
soyisim = input("Veri İkincil İsmi: ").lower().capitalize()
idekleme = (input("İD Giriniz: "))
while True:
try:
numara = int(input("Veri Numarası: "))
break
except ValueError:
print("Harf Yazamazsınız. Lütfen Değer Giriniz! ")
self.cursor.execute("INSERT INTO okul VALUES('{}','{}','{}','{}')".format(idekleme,isim,soyisim,numara))
self.connect.commit()
print("Veri İsmi, İkincil İsmi, Numarası, İD'si Sırasıyla {} , {} , {} , {} , Şeklinde Kayıt Edildi".format(isim,soyisim,numara,idekleme))
def verisilme(self):
self.cursor.execute("SELECT * FROM okul")
allstudents = self.cursor.fetchall
for (students) in (allstudents):
print(students)
def verigüncelleme(self):
print("****** Veri Güncelleme ******")
def yazdır(self):
print("***** Tüm Verileri Yazdır ******")
def cıkıs(self):
self.status = False
def connectDataBase(self):
self.connect = sqlite3.connect("okul.db")
self.cursor = self.connect.cursor()
self.cursor.execute("CREATE TABLE IF NOT EXISTS okul(id INT, isim TEXT, soyisim TEXT, numara INT)")
self.connect.commit()
okula = okul("test", "turkiye")
while okula.status:
okula.run()
fetchall
fonksiyonunu cagirmayi unutmussun gibi duruyor.
bunu nasıl yapıcam biliyorsanız söylermisiniz
allstudents = self.cursor.fetchall()
1 Beğeni