• Register
0 votes
899 views

Problem :

I am using the sqlite3 to store the values into database, My problem is that I have created lineedits through which I am trying to extract values and store it to the variables and pass this variables to the insert query but i am facing below error at line values(?,?,?,?,?)......

“Sqlite3.interfaceerror: error binding parameter 0 - probably unsupported type.”

If I just hard quote the values directly to variables it gets saved into my database what is the mistake am I doing in my code?

Below 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()

Any solution on my error?

7 5 2
3,870 points

1 Answer

0 votes

Solution :

The method from where you are trying to get the text "le1.text()", doesn't stores your value in the string format. I was facing the same error, sorted out that the data type was mismatched. I converted my value to string and it worked fine for me.

Also please don't miss to add comma at the end because your execute query takes tulip as shown below:

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

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 1.1K views
1.1K views
Problem : I am trying to convert my working Python 2.7 code into Python 3 code but I am facing following error post data should be bytes, an iterable of bytes, or a file object. it cannot be of type str.
asked Nov 16, 2019 peterlaw 6.9k points
0 votes
1 answer 327 views
327 views
Problem : When I executed: pip install xgboost I got this: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/w4/w49s3mn91plbhyjwf8qjkpxc0000gn/T/pip-build-61dms1/xgboost/
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
2 answers 613 views
613 views
Problem : On installing Anaconda on Ubantu getting below Python error on miss-typed commands fatal python error: py_initialize: unable to get the locale encoding
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 182 views
182 views
Problem: I have recently started learning Python so I have only fundamental knowledge in Python. Please find below my Transaction class for your reference: class Transaction(object):     def __init__(self, company, num, price, date, is_buy):         self.company = company         ... Python and because of lockdown I am unable to find any help to fix this issue. So I am posting my question here.
asked Aug 10 Raphael Pacheco 4.9k points
1 vote
1 answer 22 views
22 views
Problem : Recently I have started learning Homebrew. Now if I try to run Homebrews brew doctor command on my Mac OS X 10.9.2 I have started receiving the below listed warning message: Warning: Python is installed at /Library/Frameworks/Python.framework Homebrew only ... /usr/local/bin/python. But still if I rerun the brew doctor command I am still facing the same warning message listed above.
asked Apr 4 morrisBson 3.2k points