I’m using eric4 (qtdesigner, pyqt, python, etc) with sqlite and I keep getting “error binding parameter 0 – probably unsupported type” when I’m running the program I’ve coded.
I’ve made some GUIs using eric4 + qtdesigner and generated dialog codes. When one of the buttons of the windows I’ve made in qtdesigner are pressed, it should access the database and would then commits and saves the information in the database. I’ve made a separate py file for accessing and saving for the database.
Here are parts of my code which are most likely sources of the error I keep getting.
At generated dialog of the ui (which I imported the separate py file):
def on_button_Save_released(self):
"""
Slot documentation goes here.
"""
# TODO: not implemented yet
Nik = self.LineEdit_Nickname.text()
NFirst = self.LineEdit_NameFirst.text()
NMid = self.LineEdit_NameMiddle.text()
NLast = self.LineEdit_NameLast.text()
BMon = self.ComboBox_BirthMonth.currentText()
BDay = self.ComboBox_BirthDay.currentText()
BYear = self.ComboBox_BirthYear.currentText()
CNum = self.LineEdit_ContactNum.text()
EM = self.LineEdit_EMail.text()
MAd = self.LineEdit_MailAdd.text()
self.NMem = NewMem()
self.NMem.input_data(Nik, NFirst, NMid, NLast, BMon, BDay, BYear, CNum, EM, MAd)
And this at the database accessing and writing which is on a separate py file:
import sqlite3
import datetime, time
con = sqlite3.connect("Members.db") #access database
cur = con.cursor() #cursor object for database
class NewMem:
def input_data(self, Nik, NFirst, NMid, NLast, BMon, BDay, BYear, CNum, EM, MAd):
def adapt_datetime(ts):
return time.mktime(ts.timetuple())
#Get current time and date
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
now = datetime.datetime.now()
#created if first time to make a table
try:
cur.execute('create table Members (ID integer primary key autoincrement not null, Nick string not null, NameFirst string, NameMiddle string, NameLast string, BirthMonth string, BirthDay string, BirthYear string, ContactNum string, EMail string, MailAdd string, MemberSince string)')
except:
pass
cur.execute("insert into Members (Nick,NameFirst,NameMiddle,NameLast,BirthMonth,BirthDay,BirthYear,ContactNum,EMail,MailAdd,MemberSince) values (?,?,?,?,?,?,?,?,?,?,?)",(Nik, NFirst, NMid, NLast, BMon, BDay, BYear, CNum, EM, MAd, now))
con.commit()
cur.close()
con.close()
I’ve read some searches at google that it might be the quotation marks and ? parameters but I’ve checked and they are correct it seems. Also read somewhere that it has to do with the character map (UTF?) but I honestly don’t know how to check…
I’ve also added some print to see if they are showing the correct data I’ve input and they are correct. So it’s quite boggling why I’m still getting the error.
Any help is much appreciated bows deeply
QlineEdit.text()returns aQString. Pass it to theunicodeconstructor to get something usable.