Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

Inserting image and date into sqlite3 database



  • Hi, I'm trying to insert the following into my sqlite3 database but it does not work. Please below is my code, I need assistance please. Thanks in advance.

         def ADD__NEW_DETAILS(self):
    
                name = self.ui.lineEdit_38.text()
                telephone = self.ui.lineEdit_32.text()
                email = self.ui.lineEdit_25.text()
    	    dob = self.ui.dateEdit.date()
                image = self.ui.Display_label.text()
    
    
                if ( name  and telephone and email and image !=""):
    
    
                    try:
    
                        cur.execute(("INSERT INTO personal_details (name, telephone_no, email,birth_date, photo) VALUES(?,?,?,?,?)"), (name, telephone ,email ,dob ,image,))
                        con.commit()
                        QMessageBox.information(self, "Success", "Details Has Been Added")
    
    		    name = self.ui.lineEdit_38.clear()
    		    telephone = self.ui.lineEdit_32.clear()
    		    email = self.ui.lineEdit_25.clear()
    		    dob = self.ui.dateEdit.clear()
    		    image = self.ui.Display_label.clear()
    
    
                    except:
                          QMessageBox.information(self, "Warning", "Details Has Not Been Added")
    
                else:
                    QMessageBox.information(self, "Warning", "All Fields Are Required Cannot Be Empty")
    
    		name = self.ui.lineEdit_38.clear()
    		telephone = self.ui.lineEdit_32.clear()
    		email = self.ui.lineEdit_25.clear()
    		dob = self.ui.dateEdit.clear()
    		image = self.ui.Display_label.clear()
    


  • @LT-K101
    So far as I can see you have chosen to use only Python library to access database, nothing to do with Qt, so I would ask a Python or SQLite forum for help.



  • YMMV inserting images into a database. BLOB field support is often a special case, if supported by the DB at all.


Log in to reply