Hoşgeldin Misafir

Piton MySQL Serverden Listbox'a Veri Çekme

MiRaT

13 Kas 2017
2,077 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
Kod:
#-*-coding:cp1254-*-
import MySQLdb
from Tkinter import *

db = MySQLdb.connect("localhost","root","123456","world" )
cursor = db.cursor()

Form=Tk()

Lb=Listbox(Form)
Lb.pack()

sql = "SELECT Plaka,isim FROM iller"
cursor.execute(sql)
# fetchall komutuyla tüm kayıtlar alınıyor
results = cursor.fetchall()
for row in results:
    Plaka = row[0]
    isim = row[1]
    for item in [Plaka,isim]:
        Lb.insert(END, item)


mainloop()