ich mach gerade meine ersten Versuche in python. Ich möchte mit einem Python-Projekt eine postgresql-Datenbank steuern, so etwa nach dem folgenden Python-Skript, irgendwann auch mit GUI:
Code: Alles auswählen
#!/usr/bin/python3
#coding=utf8
import postgresql
import getpass
import tkinter
import sys
pw=getpass.getpass("Passwort: ")
db = postgresql.open(user = 'postgres', password = pw, database = 'Praxisverwaltung', port = 5432)
liste = (db.prepare("SELECT id||' '||nachname||' '||vorname, strasse FROM klientenmodul WHERE behandlung = true ORDER BY id ASC"))
main = tkinter.Tk()
fr = tkinter.Frame(main, height = 100, width = 300, bg="#FFFFFF", bd=10)
fr.pack()
mBar = tkinter.Menu(main)
mFile = tkinter.Menu(mBar)
mFile.add_command(label = "Neu")
mBar.add_cascade(label = "Datei", menu=mFile)
main["menu"] = mBar
label1 = tkinter.Label(main, text='Daten', bg = "#AFFFFF", width=60, height=5)
label1.pack()
li = tkinter.Listbox(main, width = 50, height=10, bg="#AAAAAA", font=('Ubuntu', 20))
for item in liste:
li.insert("end", item)
li.pack()
def ende():
sys.exit()
button = tkinter.Button(main, text="Ende", command = ende)
button.pack()
main.mainloop()
db.close()
Ich hoffe, ich stelle keine zu banale Frage.
Besten Dank für Hilfestellungen und Ideen.
Gruß,
bernie