def ok_clicked(self): self.Fname = self.Fname_lineEdit.text() self.Lname = self.Lname_lineEdit.text() self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') if self.Lname == '' and self.Fname == '': QtGui.QMessageBox.warning( self, 'Guess What?', 'Both fields can\'nt be left blank simultaneously!!') elif self.Lname == '': table = self.dbu.GetByFname(self.Fname, self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() elif self.Fname == '': table = self.dbu.GetByLname(self.Lname, self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() else: table = self.dbu.GetByName(self.Fname, self.Lname, self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close()
def ok_clicked(self): self.fname = self.Fname_lineEdit.text() self.sex = 'NA' self.id_type = 'NA' if self.flag_sex == 3: self.sex = 'other' elif self.flag_sex == 2: self.sex = 'female' elif self.flag_sex == 1: self.sex = 'male' else: QtGui.QMessageBox.warning(self, 'Guess What?', 'Sex Missing!') if not self.fname: QtGui.QMessageBox.warning(self, 'Guess What?', 'First Name Missing!') self.lname = self.Lname_lineEdit.text() if not self.lname: QtGui.QMessageBox.warning(self, 'Guess What?', 'Last Name Missing!') self.address = self.adddress_lineEdit.text() if not self.address: QtGui.QMessageBox.warning(self, 'Guess What?', 'Address Missing!') if self.flag_id == 3: self.id_type = self.other_lineEdit.text() elif self.flag_id == 2: self.id_type = 'Staff Id' elif self.flag_id == 1: self.id_type = 'Student Id' else: QtGui.QMessageBox.warning(self, 'Guess What?', 'Id type Missing!') self.id_no = self.idnumber_lineEdit.text() if not self.id_no: QtGui.QMessageBox.warning(self, 'Guess What?', 'Id Number Missing!') self.mobile_no = self.contact_lineEdit.text() self.landline = self.lineEdit.text() self.vehicle_no = self.vehicle_number_lineEdit.text() if not self.vehicle_no: QtGui.QMessageBox.warning(self, 'Guess What?', 'Vehicle number Missing!') #self.vehicle_type=self.vehicletype_comboBox.text() if not self.vehicle_type: QtGui.QMessageBox.warning(self, 'Guess What?', 'vehicle type Missing!') dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') dbu.AddEntryToTable1(self.id_no, self.id_type, self.fname, self.lname, self.sex, self.address, self.mobile_no, self.landline) if self.vehicle_type != 'Pedestrian': dbu.AddEntryToTable2(self.id_no, self.vehicle_no, self.vehicle_type) if self.flag_id == 3: self.d = dbu.date1 self.t = dbu.time self.p = purpose.Ui_Form(self.id_no, self.d, self.t) self.p.show() QtGui.QMessageBox.information(self, 'Congrats!!', 'Data successfully saved!')
def __init__(self): super(Ui_Dialog,self).__init__() cfgs = MyConfigs() self.dbConnection = cfgs.Get_db_config() self.MySettings = cfgs.Get_MySetting('MySetting') self.DeptGroups = cfgs.Get_MySetting('DepartmentGroup') self.dbCon = DB_manager.DatabaseUtility(**self.dbConnection)
def __init__(self): super(Ui_MainWindow, self).__init__() cfgs = MyConfigs() connstring = cfgs.Get_db_config() self.MySettings = cfgs.Get_MySetting('MySetting') self.DeptGrp = cfgs.Get_MySetting('DepartmentGroup') self.dbCon = DB_manager.DatabaseUtility(**connstring)
def create_user(email, first_name, last_name, password1, password2): # print(user) #Non-encrypting information # email = user["email"].lower() # first_name = user["firstname"].lower() # last_name = user["lastname"].lower() email = email.lower() first_name = first_name.lower() last_name = last_name.lower() try: conn = psycopg2.connect(host=DB_manager.get_hostname(), database=DB_manager.get_database(), user=DB_manager.get_user(), password=DB_manager.get_password(), port=DB_manager.get_port()) cursor = conn.cursor() query_valid = "select count(*) from users where email = \'" + email + "\'" cursor.execute(query_valid) num = cursor.fetchone()[0] if (num > 0): #USER EXISTS ERROR CODE return -2 if (password1 == password2): pwd_context = CryptContext(schemes=["pbkdf2_sha256"], default="pbkdf2_sha256", pbkdf2_sha256__default_rounds=30000) hashed_pw = pwd_context.encrypt(password2) hex_num = "#{:06x}".format(random.randint(0, 0xFFFFFF)) query_insert = "insert into users (email, first_name, last_name, date_created, password, color) VALUES ('{}', '{}', '{}', CURRENT_DATE,'{}', '{}')".format( email, first_name, last_name, hashed_pw, hex_num) cursor.execute(query_insert) else: return -4 return 0 except (Exception, psycopg2.Error) as error: #DATABASE CONNECTION/OTHER JSON ERROR CODE return -1 finally: if (conn): conn.commit() cursor.close() conn.close()
def ok_clicked(self): self.address=self.lineEdit.text() self.dbu=DB_manager.DatabaseUtility('icpms','person','vehicle','purpose') if not self.address: QtGui.QMessageBox.warning(self, 'Guess What?', 'Address field Empty!!') else: table=self.dbu.GetByAddress(self.address,self.date) self.dr=data_retreived.Ui_Form(table) self.dr.show() self.close()
def __init__(self, database, tableName): super().__init__() self.tableName = tableName uic.loadUi('simple_db_form.ui', self) self.setWindowTitle('APP Pyqt Gui') self.dbu = DB_manager.DatabaseUtility(database=database) self.pushButton.clicked.connect(self.Commit) self.worke = DB_handler(db=self.dbu, tableName=self.tableName) self.worke.sig1.connect(self.UpdateTree) self.worke.start()
def get_id(email): email = email.lower() try: conn = psycopg2.connect(host = DB_manager.get_hostname(), database = DB_manager.get_database(), user = DB_manager.get_user(), password = DB_manager.get_password(), port = DB_manager.get_port()) cursor = conn.cursor() q = "select user_id from users where email = '{}'".format(email) cursor.execute(q) return cursor.fetchone()[0] except (Exception, psycopg2.Error) as error: #DATABASE CONNECTION/OTHER JSON ERROR CODE return -1 finally: if(conn): conn.commit() cursor.close() conn.close()
def insertFact(): if request.method == 'POST': category = request.form['select_category'] fact = request.form['input_random_fact'] # Refuse if no fact was added if fact == '': flash('Please insert the random fact', 'error') return redirect(url_for('index')) # Add new fact if category != '': dm.insertFact(conn_str=connection_secret.CONN_STR, cat=category, fact=fact) flash('File successfully uploaded', 'info') return redirect(url_for('index'))
def ok_btn_clicked(self): #self.de=data_entry.Ui_Form() self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') self.whom_to_visit = self.lineEdit.text() self.relationship = self.lineEdit_2.text() self.purpose_of_visit = self.lineEdit_3.text() #print self.id_no,self.whom_to_visit,self.relationship,self.purpose_of_visit self.dbu.AddEntryToTable3(self.id_no, self.date1, self.time, self.whom_to_visit, self.relationship, self.purpose_of_visit) self.close()
def index(): if request.method == 'POST': category = request.form['cat_button'] # If user asks for facts from other users if category == 'usr': usr_fact = dm.randomFact(conn_str=connection_secret.CONN_STR, src='usr') if usr_fact is None: flash('No facts from random users', 'error') return redirect(request.url) else: return render_template("index.html", randomFact=usr_fact[1], category=usr_fact[0], cat_list=cat_list) # Facts stored in our DB else: _, fact = dm.randomFact(conn_str=connection_secret.CONN_STR, key=category) return render_template("index.html", randomFact=fact, category=category, cat_list=cat_list) # Otherwise give random fact else: category, fact = dm.randomFact(conn_str=connection_secret.CONN_STR) return render_template("index.html", randomFact=fact, category=category, cat_list=cat_list)
def new_user(email, password): #Non-encrypting information email = email.lower() try: conn = psycopg2.connect(host = DB_manager.get_hostname(), database = DB_manager.get_database(), user = DB_manager.get_user(), password = DB_manager.get_password(), port = DB_manager.get_port()) cursor = conn.cursor() query_valid = "select count(*) from users where email = \'" + email + "\'" cursor.execute(query_valid) num = cursor.fetchone()[0] if(num != 1): return -1 query_get_pass = "******" + email + "\'" cursor.execute(query_get_pass) hashed_pw = cursor.fetchone()[0] pwd_context = CryptContext(schemes=["pbkdf2_sha256"], default = "pbkdf2_sha256", pbkdf2_sha256__default_rounds=30000) if(pwd_context.verify(password.encode("utf8"), hashed_pw)): return 0 else: return -1 except (Exception, psycopg2.Error) as error: #DATABASE CONNECTION/OTHER JSON ERROR CODE return -1 finally: if(conn): conn.commit() cursor.close() conn.close()
def __init__(self): super(Window, self).__init__() uic.loadUi('material.ui', self) self.db = 'patient_try' self.identityTable = 'patient' self.visitTable = 'visits' self.dbu = DB_manager.DatabaseUtility(self.db) self.qu = Queue() self.worker = Worker(qu=self.qu, parent=self) self.entry_app = entry.Entry(self, self.dbu, self.identityTable, self.visitTable, self.qu) self.katar_app = katar.Katar(self, self.dbu, self.identityTable, self.visitTable, self.qu) self.addPushButton.clicked.connect(self.katar_app.update_queue) self.worker.start()
def __init__(self): super(Ui_login, self).__init__() cfgs = MyConfigs() connstring = cfgs.Get_db_config() self.dbCon = DB_manager.DatabaseUtility(**connstring)
# cookie_choice = request.form.get('cookie_type') # # #var to hold num of cookies # order_quantity = request.form.get('quantity') #DB_manager.getQuantity() # # DB_orm.add_order_to_db(cookie_choice,order_quantity) # #prices = cookie.price # # #print(cookie.price) # # order_total = [price[2] for price in order_quantity] # # price = request.form[''] # #print(prices) # for c in cookies: # print(c) # #cook_price = [price[2] for price in cookies] # #print(cookies) # print(order_quantity) # return render_template('order.html', cookies=cookies) # @app.route('/order_saved', methods=['Post']) # def save_order(): # banana = request.args.get('cookie_type') # bananas = request.args.get('quantity') # DB_orm.add_order_to_db(banana, bananas) # return render_template('order_saved.html', order=order) if __name__ == '__main__': # DB_orm.DB_setup() DB_manager.create_db() app.run(debug=True) #kind of like the web server #google flask template
def store_data_in_DB(): db_manager = DB_manager.DBManager() db_manager.connect_to_DB() db_manager.setup_DB() db_manager.close_DB()
def __init__(self, schema, table, tableLH, parent = None): super( MyDatabase, self ).__init__(parent) self.DB = DB_manager.DatabaseUtility(schema, table) self.DB_history = DB_manager.DatabaseUtility(schema, tableLH) self.setupUi(self) self.setObjectName('myDatabase_UI') #-----------------------------------------------------------------------------------------------------------------# #-----------------------------------------------------------------------------------------------------------------# verticalLayout = self.verticalLayout_L_expanded self.horizontalLayout_id = qg.QHBoxLayout() self.horizontalLayout_id_history = qg.QHBoxLayout() self.horizontalLayout_shot = qg.QHBoxLayout() self.horizontalLayout_date = qg.QHBoxLayout() self.horizontalLayout_time = qg.QHBoxLayout() self.horizontalLayout_artist = qg.QHBoxLayout() self.horizontalLayout_startFrame = qg.QHBoxLayout() self.horizontalLayout_endFrame = qg.QHBoxLayout() self.horizontalLayout_mastershot = qg.QHBoxLayout() self.horizontalLayout_status = qg.QHBoxLayout() self.toolButton_id = qg.QToolButton() self.toolButton_id_history = qg.QToolButton() self.toolButton_shot = qg.QToolButton() self.toolButton_date = qg.QToolButton() self.toolButton_time = qg.QToolButton() self.toolButton_artist = qg.QToolButton() self.toolButton_startFrame = qg.QToolButton() self.toolButton_endFrame = qg.QToolButton() self.toolButton_mastershot = qg.QToolButton() self.toolButton_status = qg.QToolButton() expanded_toolButton_list = [self.toolButton_id, self.toolButton_id_history, self.toolButton_shot, self.toolButton_date, self.toolButton_time, self.toolButton_artist, self.toolButton_startFrame, self.toolButton_endFrame, self.toolButton_mastershot, self.toolButton_status] for expanded_toolButton in expanded_toolButton_list: expanded_toolButton.setText("+") disabled_toolButton_list = [self.toolButton_id, self.toolButton_id_history, self.toolButton_shot, self.toolButton_date, self.toolButton_time, self.toolButton_artist, self.toolButton_startFrame, self.toolButton_endFrame, self.toolButton_mastershot, self.toolButton_status] for disabled_toolButton in disabled_toolButton_list: disabled_toolButton.setEnabled(False) fl = FrameLayout(title="Filter Header") verticalLayout.addWidget(fl) self.checkBox_id = qg.QCheckBox("ID") self.checkBox_id_history = qg.QCheckBox("ID_History") self.checkBox_shot = qg.QCheckBox("Shot") self.checkBox_date = qg.QCheckBox("Date") self.checkBox_time = qg.QCheckBox("Time") self.checkBox_startFrame = qg.QCheckBox("Start_Frame") self.checkBox_endFrame = qg.QCheckBox("End_Frame") self.checkBox_artist = qg.QCheckBox("Artist") self.checkBox_mastershot = qg.QCheckBox("Mastershot") self.checkBox_status = qg.QCheckBox("Status") self.horizontalLayout_id.addWidget(self.checkBox_id) self.horizontalLayout_id.addWidget(self.toolButton_id) self.horizontalLayout_id_history.addWidget(self.checkBox_id_history) self.horizontalLayout_id_history.addWidget(self.toolButton_id_history) self.horizontalLayout_shot.addWidget(self.checkBox_shot) self.horizontalLayout_shot.addWidget(self.toolButton_shot) self.horizontalLayout_date.addWidget(self.checkBox_date) self.horizontalLayout_date.addWidget(self.toolButton_date) self.horizontalLayout_time.addWidget(self.checkBox_time) self.horizontalLayout_time.addWidget(self.toolButton_time) self.horizontalLayout_artist.addWidget(self.checkBox_artist) self.horizontalLayout_artist.addWidget(self.toolButton_artist) self.horizontalLayout_startFrame.addWidget(self.checkBox_startFrame) self.horizontalLayout_startFrame.addWidget(self.toolButton_startFrame) self.horizontalLayout_endFrame.addWidget(self.checkBox_endFrame) self.horizontalLayout_endFrame.addWidget(self.toolButton_endFrame) self.horizontalLayout_mastershot.addWidget(self.checkBox_mastershot) self.horizontalLayout_mastershot.addWidget(self.toolButton_mastershot) self.horizontalLayout_status.addWidget(self.checkBox_status) self.horizontalLayout_status.addWidget(self.toolButton_status) fl.addLayout(self.horizontalLayout_id) fl.addLayout(self.horizontalLayout_id_history) fl.addLayout(self.horizontalLayout_shot) fl.addLayout(self.horizontalLayout_date) fl.addLayout(self.horizontalLayout_time) fl.addLayout(self.horizontalLayout_artist) fl.addLayout(self.horizontalLayout_startFrame) fl.addLayout(self.horizontalLayout_endFrame) fl.addLayout(self.horizontalLayout_mastershot) fl.addLayout(self.horizontalLayout_status) self.listWidget_bodyFilter = qg.QListWidget() self.listWidget_bodyFilter.setSelectionMode(qg.QAbstractItemView.ExtendedSelection) fl.addWidget(self.listWidget_bodyFilter) self.pushButton_refliter = qg.QPushButton("Refilter") fl.addWidget(self.pushButton_refliter) verticalSpacer = qg.QSpacerItem(120, 100, qg.QSizePolicy.Minimum, qg.QSizePolicy.Expanding) verticalLayout.addItem(verticalSpacer) #-----------------------------------------------------------------------------------------------------------------# #-----------------------------------------------------------------------------------------------------------------# self.updateCheckBox() self.updateTable() self.updateTable_history() self.tableWidget_data.itemClicked.connect(self.updateTable_history) self.pushButton_save.clicked.connect(self.saveTable) self.pushButton_refliter.clicked.connect(self.updateTable) self.toolButton_godMode.clicked.connect(self.myDatabaseExpanded) self.checkBox_artist.toggled.connect(self.setEnabled_artist) self.checkBox_mastershot.toggled.connect(self.setEnabled_mastershot) self.checkBox_status.toggled.connect(self.setEnabled_status) self.toolButton_status.clicked.connect(self.statusFilter)
def order(): cookieLists = DB_manager.showCookie("%") #change to new return render_template('order.html', cookieList=cookieLists)
def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.dbCon = DB_manager.DatabaseUtility("autoswitch", "boards")
def __init__(self): QtGui.QWidget.__init__(self) self.dbu = DB_manager.DatabaseUtility() self.setupUi(self)
def __init__(self): QtGui.QDialog.__init__(self) self.dbu = db.DatabaseUtility('UsernamePassword_DB', 'masterTable') self.setupUi(self) self.confirm = None
def __init__(self, database, tableName): QtWidgets.QWidget.__init__(self) #엑시멀코드 수정사항 self.dbu = DB_manager.DatabaseUtility(database, tableName) self.setupUi(self) #셀프를 빼먹지 말것 #여기 깔리는 순서가 상관이 있는지는 모르겠다마는 self.UpdateTree()
def ok_btn_clicked(self): self.choice = int(self.choice_lineEdit.text()) temp_date = (self.dateEdit.date()) self.date = str(temp_date.toPyDate()) if self.choice == 1: self.sb_name = search_by_name.Ui_Dialog(self.date) self.sb_name.show() self.close() elif self.choice == 2: self.sb_addr = search_by_address.Ui_Dialog(self.date) self.sb_addr.show() self.close() elif self.choice == 3: self.sb_id = search_by_id.Ui_Dialog(self.date) self.sb_id.show() self.close() elif self.choice == 4: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') table = self.dbu.GetLast30Visits(self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() elif self.choice == 5: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') table = self.dbu.GetLast30TwoWheelers(self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() elif self.choice == 6: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') table = self.dbu.GetLast30FourWheelers(self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() elif self.choice == 7: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') table = self.dbu.GetLast30Pedestrians(self.date) self.dr = data_retreived.Ui_Form(table) self.dr.show() self.close() elif self.choice == 8: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfPersons(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of persons are: %s ' % c) self.close() elif self.choice == 9: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfMales(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of male visits are: %s ' % c) self.close() elif self.choice == 10: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfFemales(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of female visits are: %s ' % c) self.close() elif self.choice == 11: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfStudents(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of student visits are: %s ' % c) self.close() elif self.choice == 12: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfStaff(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of staff visits are: %s ' % c) self.close() elif self.choice == 13: self.dbu = DB_manager.DatabaseUtility('icpms', 'person', 'vehicle', 'purpose') count = self.dbu.GetNumberOfOutsiders(self.date) c = str(count[0]) QtGui.QMessageBox.information( self, 'No of Persons', 'Total number of outsiders are: %s ' % c) self.close() else: QtGui.QMessageBox.warning(self, 'Dang it!!', 'Invalid Entry!!')
def __init__(self, database, tableName): QtGui.QWidget.__init__(self) self.dbu = DB_manager.DatabaseUtility(database, tableName) self.setupUi(self) self.UpdateTree()
def __init__(self): cfgs = MyConfigs() connstring = cfgs.Get_db_config() self.dbCon = DB_manager.DatabaseUtility(**connstring)
a = re.findall('\d+', line) for k in a: sum += k gongshi = (sum) i += 1 elif (i % 7 == 5): a = re.findall('\d+', line) for k in a: sum += k chuga = (sum) i += 1 elif (i % 7 == 0): date = line[:-2] i += 1 flag = 0 first = True #print('flag:',flag) if flag >= 2: break file_.close() #module reload #import importlib #importlib.reload(Dh) db = Dh.DBHelper() for obj in KT_list: db.db_insertCrawlingData(obj.img_link, obj.model, obj.name, obj.out_price, obj.gongshi, obj.chuga, obj.danmal, obj.date) db.db_free()
'Code': [], 'Item Type': [], 'Quantity': [], 'Batch no.': [], 'Expiry': [], 'Price': [], 'Discount %': [], 'VAT %': [], 'Amount': [] } sheetHeaders = [ 'Item', 'Quantity', 'Code', 'Item Type', 'Batch no.', 'Expiry', 'Price', 'Discount %', 'VAT %', 'Amount' ] dbu = DB_manager.DatabaseUtility('MedDB', 'DemoDB') dbu.AddEntryToTable('M1', 1, 'MED', 11, '2018-06-20', 20, 18, 1, 1) dbu.AddEntryToTable('M2', 2, 'MED', 12, '2018-06-21', 25, 18, 2, 2) dbu.AddEntryToTable('M3', 3, 'SYP', 13, '2018-06-22', 30, 18, 3, 3) dbu.AddEntryToTable('M4', 4, 'SYP', 14, '2018-06-23', 40, 18, 4, 4) dbu.AddEntryToTable('M5', 5, 'FMCG', 15, '2018-06-24', 50, 18, 5, 5) gpname = "Default" gdname = "Default" ganame = "Default" gpaddr = "Default" gpcont = "Default" gtamt = 100 gtdisc = 20 gttax = 18
def __init__(self): QtGui.QDialog.__init__(self) self.dbu = db.DatabaseUtility('db', 'login') self.setupUi(self) self.confirm = None