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 259 Views 1 Watching
  • 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 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()
    
    JonBJ 1 Reply Last reply
    0
    • L LT-K101

      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()
      
      JonBJ Online
      JonBJ Online
      JonB
      wrote on 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
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on 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.

        If you meet the AI on the road, kill it.

        1 Reply Last reply
        2

        • Login

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