-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveAIRLINE.py
More file actions
44 lines (30 loc) · 1.01 KB
/
Copy pathsaveAIRLINE.py
File metadata and controls
44 lines (30 loc) · 1.01 KB
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
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUiType
import sys
import mysql.connector as con
ui,_=loadUiType('/home/ateium/SQL_PROJECT/saveAIRLINE.ui')
class MainApp(QWidget,ui):
def __init__(self):
QWidget.__init__(self)
self.setupUi(self)
self.b1.clicked.connect(self.savedb)
def savedb(self):
try:
mydb = con.connect(host="localhost",user="root", password="admin",db="AIRPORT")
cursor = mydb.cursor()
NAME = self.tb1.text()
cursor.execute("insert into AIRLINE(AL_NAME) values('"+ NAME +"')");
mydb.commit()
QMessageBox.information(self,"DB Insert","Details saved successfully")
except Exception as e:
print(e)
QMessageBox.information(self,"DB Insert","Error in save db")
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()