Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inserting image and date into sqlite3 database

Inserting image and date into sqlite3 database

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 198 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LT-K101
    wrote on 14 Oct 2021, 15:21 last edited by
    #1

    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()
    
    J 1 Reply Last reply 14 Oct 2021, 15:39
    0
    • L LT-K101
      14 Oct 2021, 15:21

      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()
      
      J Offline
      J Offline
      JonB
      wrote on 14 Oct 2021, 15:39 last edited by
      #2

      @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.

      1 Reply Last reply
      3
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 14 Oct 2021, 18:19 last edited by
        #3

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

        1 Reply Last reply
        2

        1/3

        14 Oct 2021, 15:21

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved