python - sqlite InterfaceError: Error binding parameter 0 - probably unsupported type

Multi tool use
Multi tool use












1















i am using sqlite3 to store values into database, My problem is i have created lineedits through which i extract values and store it to variables and pass this variables to insert query but i am getting above error at line values(?,?,?,?,?)......if i hard quote the values directly to variables it gets saved into database what is the mistake am i doing? please help.......here is my code



            self.uname = self.le1.text()
self.passwd = self.le2.text()
self.permssn = self.le3.text()
self.queryCurs.execute('''CREATE TABLE IF NOT EXISTS USER
(USERNAME TEXT NOT NULL, PASSWORD TEXT NOT NULL, PERMISSION TEXT NOT NULL)''')
self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION)
VALUES(?,?,?)''',(self.uname,self.passwd,self.permssn))
print ('inserted row')
self.createDb.commit()


where am i going wrong?










share|improve this question



























    1















    i am using sqlite3 to store values into database, My problem is i have created lineedits through which i extract values and store it to variables and pass this variables to insert query but i am getting above error at line values(?,?,?,?,?)......if i hard quote the values directly to variables it gets saved into database what is the mistake am i doing? please help.......here is my code



                self.uname = self.le1.text()
    self.passwd = self.le2.text()
    self.permssn = self.le3.text()
    self.queryCurs.execute('''CREATE TABLE IF NOT EXISTS USER
    (USERNAME TEXT NOT NULL, PASSWORD TEXT NOT NULL, PERMISSION TEXT NOT NULL)''')
    self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION)
    VALUES(?,?,?)''',(self.uname,self.passwd,self.permssn))
    print ('inserted row')
    self.createDb.commit()


    where am i going wrong?










    share|improve this question

























      1












      1








      1








      i am using sqlite3 to store values into database, My problem is i have created lineedits through which i extract values and store it to variables and pass this variables to insert query but i am getting above error at line values(?,?,?,?,?)......if i hard quote the values directly to variables it gets saved into database what is the mistake am i doing? please help.......here is my code



                  self.uname = self.le1.text()
      self.passwd = self.le2.text()
      self.permssn = self.le3.text()
      self.queryCurs.execute('''CREATE TABLE IF NOT EXISTS USER
      (USERNAME TEXT NOT NULL, PASSWORD TEXT NOT NULL, PERMISSION TEXT NOT NULL)''')
      self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION)
      VALUES(?,?,?)''',(self.uname,self.passwd,self.permssn))
      print ('inserted row')
      self.createDb.commit()


      where am i going wrong?










      share|improve this question














      i am using sqlite3 to store values into database, My problem is i have created lineedits through which i extract values and store it to variables and pass this variables to insert query but i am getting above error at line values(?,?,?,?,?)......if i hard quote the values directly to variables it gets saved into database what is the mistake am i doing? please help.......here is my code



                  self.uname = self.le1.text()
      self.passwd = self.le2.text()
      self.permssn = self.le3.text()
      self.queryCurs.execute('''CREATE TABLE IF NOT EXISTS USER
      (USERNAME TEXT NOT NULL, PASSWORD TEXT NOT NULL, PERMISSION TEXT NOT NULL)''')
      self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION)
      VALUES(?,?,?)''',(self.uname,self.passwd,self.permssn))
      print ('inserted row')
      self.createDb.commit()


      where am i going wrong?







      python-2.7 sqlite3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 20 '14 at 10:17









      darshan kataridarshan katari

      37211




      37211
























          2 Answers
          2






          active

          oldest

          votes


















          0














          The method from where you're getting the text "le1.text()", doesn't stores the value in string format. I was getting the same error, sorted out that my data type was mismatched. I converted this value to string and it worked fine.



          Also don't miss to add comma in the end because the execute query takes tulip.



          self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) 
          VALUES(?,?,?)''',(str(self.uname),str(self.passwd),str(self.permssn),))





          share|improve this answer































            -3














            Values should be in touple (square brackets), like this:



            self.queryCurs.execute("INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])


            Since you add values at the same order as columns in your table are, you don't really need them in your query, so this will also work:



            self.queryCurs.execute("INSERT INTO USER VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])





            share|improve this answer
























            • Tuples use parentheses, and work just fine.

              – CL.
              Aug 24 '14 at 16:26











            • not for me, I've tested his code and it worked only when I've changed it like in my answer

              – Aleksandar
              Aug 25 '14 at 6:11











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21231264%2fpython-sqlite-interfaceerror-error-binding-parameter-0-probably-unsupported%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The method from where you're getting the text "le1.text()", doesn't stores the value in string format. I was getting the same error, sorted out that my data type was mismatched. I converted this value to string and it worked fine.



            Also don't miss to add comma in the end because the execute query takes tulip.



            self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) 
            VALUES(?,?,?)''',(str(self.uname),str(self.passwd),str(self.permssn),))





            share|improve this answer




























              0














              The method from where you're getting the text "le1.text()", doesn't stores the value in string format. I was getting the same error, sorted out that my data type was mismatched. I converted this value to string and it worked fine.



              Also don't miss to add comma in the end because the execute query takes tulip.



              self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) 
              VALUES(?,?,?)''',(str(self.uname),str(self.passwd),str(self.permssn),))





              share|improve this answer


























                0












                0








                0







                The method from where you're getting the text "le1.text()", doesn't stores the value in string format. I was getting the same error, sorted out that my data type was mismatched. I converted this value to string and it worked fine.



                Also don't miss to add comma in the end because the execute query takes tulip.



                self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) 
                VALUES(?,?,?)''',(str(self.uname),str(self.passwd),str(self.permssn),))





                share|improve this answer













                The method from where you're getting the text "le1.text()", doesn't stores the value in string format. I was getting the same error, sorted out that my data type was mismatched. I converted this value to string and it worked fine.



                Also don't miss to add comma in the end because the execute query takes tulip.



                self.queryCurs.execute('''INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) 
                VALUES(?,?,?)''',(str(self.uname),str(self.passwd),str(self.permssn),))






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 28 '16 at 7:10









                Anum SherazAnum Sheraz

                547415




                547415

























                    -3














                    Values should be in touple (square brackets), like this:



                    self.queryCurs.execute("INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])


                    Since you add values at the same order as columns in your table are, you don't really need them in your query, so this will also work:



                    self.queryCurs.execute("INSERT INTO USER VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])





                    share|improve this answer
























                    • Tuples use parentheses, and work just fine.

                      – CL.
                      Aug 24 '14 at 16:26











                    • not for me, I've tested his code and it worked only when I've changed it like in my answer

                      – Aleksandar
                      Aug 25 '14 at 6:11
















                    -3














                    Values should be in touple (square brackets), like this:



                    self.queryCurs.execute("INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])


                    Since you add values at the same order as columns in your table are, you don't really need them in your query, so this will also work:



                    self.queryCurs.execute("INSERT INTO USER VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])





                    share|improve this answer
























                    • Tuples use parentheses, and work just fine.

                      – CL.
                      Aug 24 '14 at 16:26











                    • not for me, I've tested his code and it worked only when I've changed it like in my answer

                      – Aleksandar
                      Aug 25 '14 at 6:11














                    -3












                    -3








                    -3







                    Values should be in touple (square brackets), like this:



                    self.queryCurs.execute("INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])


                    Since you add values at the same order as columns in your table are, you don't really need them in your query, so this will also work:



                    self.queryCurs.execute("INSERT INTO USER VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])





                    share|improve this answer













                    Values should be in touple (square brackets), like this:



                    self.queryCurs.execute("INSERT INTO USER(USERNAME, PASSWORD, PERMISSION) VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])


                    Since you add values at the same order as columns in your table are, you don't really need them in your query, so this will also work:



                    self.queryCurs.execute("INSERT INTO USER VALUES(?,?,?)",[self.uname, self.passwd, self.permssn])






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 30 '14 at 19:07









                    AleksandarAleksandar

                    2,13831946




                    2,13831946













                    • Tuples use parentheses, and work just fine.

                      – CL.
                      Aug 24 '14 at 16:26











                    • not for me, I've tested his code and it worked only when I've changed it like in my answer

                      – Aleksandar
                      Aug 25 '14 at 6:11



















                    • Tuples use parentheses, and work just fine.

                      – CL.
                      Aug 24 '14 at 16:26











                    • not for me, I've tested his code and it worked only when I've changed it like in my answer

                      – Aleksandar
                      Aug 25 '14 at 6:11

















                    Tuples use parentheses, and work just fine.

                    – CL.
                    Aug 24 '14 at 16:26





                    Tuples use parentheses, and work just fine.

                    – CL.
                    Aug 24 '14 at 16:26













                    not for me, I've tested his code and it worked only when I've changed it like in my answer

                    – Aleksandar
                    Aug 25 '14 at 6:11





                    not for me, I've tested his code and it worked only when I've changed it like in my answer

                    – Aleksandar
                    Aug 25 '14 at 6:11


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21231264%2fpython-sqlite-interfaceerror-error-binding-parameter-0-probably-unsupported%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    rUt5,SkKOPRAZWd,cNAwkHINnv3d9pKvelEDx 8UTW m1lMqf cMBN7HM0UA
                    XJ8u8 cCtAxe,IH

                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas