NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

main classıı
from Sample import SQLite3
sql = SQLite3.SQL()
class Person:
def __init__(self, name, surname, age, phone):
self.name = name
self.surname = surname
self.age = age
self.phone = phone

def add(self):
sql.insert(self.name,self.surname,self.age,self.phone)
cikis = 0
while cikis == 0:
secim = int(input("İşlem Seçiniz:n1-Listelemen2-Eklen3-İsim ile Araman4-Düzeltn5-Siln6-Çıkışn"))
if secim ==1:
sql.select()
elif secim == 2:
name = input("İsim giriniz:")
surname = input("Soyisim giriniz:")
age = input("Yaş giriniz:")
phone = input("Telefon giriniz:")
p = Person(name,surname,age,phone)
p.add()
elif secim == 3:
name = input("İsim giriniz:")
sql.search(name)
elif secim == 4:
sql.select()
id = input("ID giriniz:")
name = input("İsim giriniz:")
surname = input("Soyisim giriniz:")
age = input("Yaş giriniz:")
phone = input("Telefon giriniz:")
sql.update(id,name,surname,age,phone)
elif secim == 5:
sql.select()
id = input("ID giriniz:")
sql.delete(id)
elif secim == 6:
cikis=1
else:
print("Yanlış seçim yaptınız.")
-*********************************************************
import sqlite3
class SQL:
def __init__(self):
self.conn = sqlite3.connect("sql.db")
self.cur = self.conn.cursor()

def create(self):
self.conn.execute('CREATE TABLE person (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, surname TEXT, age TINYINT,phone TEXT)')
self.conn.commit()

def select(self):
self.cur.execute('SELECT * FROM person')
rows = self.cur.fetchall()
for row in rows:
print(row)

def insert(self,name, surname, age, phone):
self.cur.execute('INSERT INTO person(name, surname, age, phone) Values("'+name+'","'+surname+'",'+age+',"'+phone+'")')
self.conn.commit()
print("Executed successfully.")

def update(self, id, name, surname, age, phone):
self.cur.execute('UPDATE person SET name = "'+name+'", surname = "'+surname+'", age = "'+age+'", phone = "'+phone+'" WHERE id = "'+id+'"')
self.conn.commit()

print("Executed successfully.")

def delete(self,id):
self.cur.execute('DELETE FROM person WHERE id = "'+id+'"')
self.conn.commit()
print("Executed successfully.")

def search(self,name):
self.cur.execute('SELECT * FROM person WHERE name = "'+name+'"')
rows = self.cur.fetchall()
if rows:
for row in rows:
print(row)
else:
print("No record found.")

********************************************************************************************************************
berkin kodu

import sqlite3


con = sqlite3.connect("database.db")
cursor = con.cursor()

def tablo_olustur():
cursor.execute("create table if not exists kisiler (isim TEXT,yas INT,cinsiyet TEXT,maas INT) ")
con.commit()


def veri_ekle(isim,yas,cinsiyet,maas):
cursor.execute("insert into kisiler values(?,?,?,?)",(isim,yas,cinsiyet,maas))
con.commit()


def isimSirasiListeleme():
cursor.execute("select * from kisiler")
veri = cursor.fetchall()





def isimIleArama(isimAra):
cursor.execute("select * from kisiler")
veri = cursor.fetchall()

for i in range(len(veri)):
if str(veri[i][0]) == isimAra:
print("{} isimli kişinin yasi : {} cinsiyeti : {} maası:{}".format(veri[i][0],veri[i][1],veri[i][2],veri[i][3]))

def enKucukenBuyukYasMaas():
cursor.execute("select yas,maas from kisiler")
veri = cursor.fetchall()

enkYas = int(veri[0][0])
enbYas = int(veri[0][0])
enkMaas = int(veri[0][1])
enbMaas = int(veri[0][1])

for i in range(len(veri)):
if enkYas > int(veri[i][0]):
enkYas = int(veri[i][0])
if enbYas < int(veri[i][0]):
enbYas = int(veri[i][0])

if enkMaas > int(veri[i][1]):
enkMaas = int(veri[i][1])
if enbMaas < int(veri[i][1]):
enbMaas = int(veri[i][1])

print("en büyük maaş : {} en küçük maaş : {}".format(enbMaas,enkMaas))
print("en büyük yaş : {} en küçük yaş : {}".format(enbYas,enkYas))



def erkeklerinYasveMaasOrt():
cursor.execute("select yas,maas from kisiler where cinsiyet = 'e' ")
veri = cursor.fetchall()

yasTop=0
maasTop=0
for i in range(len(veri)):
yasTop+=int(veri[i][0])
maasTop+=int(veri[i][1])

yasOrt = yasTop / len(veri)
maasOrt = maasTop/ len(veri)

print("yaşların ortalaması : {}".format(yasOrt))
print("maaşların ortalaması : {}".format(maasOrt))



tablo_olustur()
"""
kisi = int(input("kaç kişi için girilecek"))

while kisi>0:
isim = input("isim :")
yas = int(input("yas:"))
cinsiyet = input("cinsiyet (E/K)")
maas = int(input("maas:"))
veri_ekle(isim,yas,cinsiyet,maas)



kisi-=1


"""

while True:

print("""
*************************
1-İsim sırası ile listeleme
2-İsim ile Arama
3-En küçük, en büyük yaş maaş
4-Erkeklerin yaş ve maaş ortalaması
5-Çıkış
*************************
""")

secim = input("seçim yapınız(çımak için q ya bas) : ")

if secim =="q":
break
elif secim =="1":
isimSirasiListeleme()
elif secim =="2":
isimAra=input("aramak istediginiz ismi giriniz :")
isimIleArama(isimAra)
elif secim =="3":
enKucukenBuyukYasMaas()
elif secim =="4":
erkeklerinYasveMaasOrt()
elif secim =="5":
exit(0)

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.