得到Sqlite InterfaceError

时间:2014-01-06 09:08:42

标签: qt sqlite python-3.x pyqt

嗨,我对python很新,所以请帮助,即使你觉得我在问一个愚蠢的怀疑。问题是我正在创建五个lineedits,必须通过单击按钮提取值。但问题是点击按钮我得到interfaceerror:错误绑定参数0 - 可能不支持类型。以下是我的代码:

class NewWindow(QtGui.QDialog):
def __init__(self, parent=None):
        super(NewWindow, self).__init__(parent)

    self.group1= QtGui.QGroupBox("Add Data")
    self.patientName = QtGui.QLabel("Name")
    self.patientEdit = QtGui.QLineEdit()

    self.patientid = QtGui.QLabel("Id")
    self.patientidEdit = QtGui.QLineEdit()
    self.patientidEdit.setValidator(QtGui.QIntValidator(self.patientidEdit))

    self.age = QtGui.QLabel("Age")
    self.ageEdit = QtGui.QLineEdit() 
    self.ageEdit.setValidator(QtGui.QIntValidator(self.ageEdit))

    self.genderlabel = QtGui.QLabel("Gender")
    self.patientgend = QtGui.QLineEdit()

    self.eyeType = QtGui.QLabel("Eye Type")
    self.eyeTypeEdit = QtGui.QLineEdit()

    self.AddData = QtGui.QPushButton("Add Data")
    self.AddData.clicked.connect(self.AddData_clicked)      

            self.databaseLayout = QtGui.QGridLayout()
    self.databaseLayout.addWidget(self.patientName,0,0)
        self.databaseLayout.addWidget(self.patientEdit,0,1)
        self.databaseLayout.addWidget(self.patientid,2,0)
        self.databaseLayout.addWidget(self.patientidEdit,2,1)
    self.databaseLayout.addWidget(self.age,4,0)
        self.databaseLayout.addWidget(self.ageEdit,4,1)
        self.databaseLayout.addWidget(self.genderlabel,6,0)
        self.databaseLayout.addWidget(self.patientgend,6,1)
        self.databaseLayout.addWidget(self.eyeType,8,0)
        self.databaseLayout.addWidget(self.eyeTypeEdit,8,1)
        self.databaseLayout.addWidget(self.AddData,10,10)

        self.group1.setLayout(self.databaseLayout)

    mainLayout = QtGui.QVBoxLayout()
    mainLayout.addWidget(self.group1)
    mainLayout.addStretch(1)
    self.setLayout(mainLayout)

def AddData_clicked(self):
    self.db_con = sqlite3.Connection
        self.db_name = "./patientData.db"
        self.createDb = sqlite3.connect(self.db_name)
            self.queryCurs = self.createDb.cursor()
    self.name = self.patientEdit.text()
    self.id = self.patientidEdit.text()
    self.age = self.ageEdit.text()
    self.gender = self.patientgend.text()
    self.eye_type = self.eyeTypeEdit.text()
    self.queryCurs.execute('''CREATE TABLE IF NOT EXISTS PATIENT
            (NAME TEXT NOT NULL, ID INTEGER PRIMARY KEY, AGE INTEGER NOT NULL, GENDER TEXT NOT NULL, EYE_TYPE TEXT NOT NULL)''')
            self.queryCurs.execute('''INSERT INTO PATIENT(NAME, ID, AGE, GENDER, EYE_TYPE) 
            VALUES(?,?,?,?,?)''',(self.name,self.id,self.age,self.gender,self.eye_type))
            print ('inserted row')
请帮帮我,我哪里错了........ 我在VALUES线上遇到错误(?,?,?,?,?).......

0 个答案:

没有答案