-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncodeddb.py
96 lines (47 loc) · 1.72 KB
/
Encodeddb.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import sys
from PyQt5.QtSql import QSqlDatabase, QSqlQuery
from PyQt5.QtWidgets import (
QApplication,
QMainWindow,
QMessageBox,
QTableWidget,
QTableWidgetItem,
)
class Encodeddb(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Encoded DataBase")
self.resize(450, 250)
# Set up the view and load the data
self.view = QTableWidget()
self.view.setColumnCount(5)
self.view.setHorizontalHeaderLabels(
["Sr.No.", "Date and Time", "Name", "TypeOfEncode", "Encoded Data"])
query = QSqlQuery("SELECT * FROM encoded_history")
while query.next():
rows = self.view.rowCount()
self.view.setRowCount(rows + 1)
self.view.setItem(rows, 0, QTableWidgetItem(str(query.value(0))))
self.view.setItem(rows, 1, QTableWidgetItem(query.value(1)))
self.view.setItem(rows, 2, QTableWidgetItem(query.value(2)))
self.view.setItem(rows, 3, QTableWidgetItem(query.value(3)))
self.view.setItem(rows, 4, QTableWidgetItem(query.value(4)))
self.view.resizeColumnsToContents()
self.setCentralWidget(self.view)
def createConnection():
con = QSqlDatabase.addDatabase("QSQLITE")
con.setDatabaseName("C:\Steganography\Stegnography_db.db")
if not con.open():
QMessageBox.critical(
None,
"QTableView Example - Error!",
"Database Error: %s" % con.lastError().databaseText(),
)
return False
return True
app = QApplication(sys.argv)
if not createConnection():
sys.exit(1)
win = Encodeddb()
win.show()
sys.exit(app.exec_())