-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallPlayers.pyw
35 lines (32 loc) · 960 Bytes
/
allPlayers.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys, psycopg2
from PyQt5.QtWidgets import QDialog, QApplication, QTableWidgetItem
import pymsgbox
from allPlayerUI import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
password = pymsgbox.prompt("Please enter the database password: ")
conn = psycopg2.connect(host="localhost",database="arnold",user="postgres",password=password)
curs = conn.cursor()
query = """
SELECT first_name, last_name
FROM players
"""
curs.execute(query)
players = curs.fetchall()
self.ui.tableWidgetName.setRowCount(len(players))
row = 0
for item in players:
first_name = QTableWidgetItem(item[0])
last_name = QTableWidgetItem(item[1])
self.ui.tableWidgetName.setItem(row, 0, first_name)
self.ui.tableWidgetName.setItem(row, 1, last_name)
row += 1
self.show()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())