PDA

View Full Version : Using unsupported buffer type: XX (parameter: XX) QMYSQL3: Unable to bind value



intel04
21st October 2012, 13:30
I have been seaching google for all day. And I could not find any result.



#!/usr/bin/env python
# -*- coding: iso-8859-9 -*-

from PyQt4 import QtCore, QtGui, QtSql

class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.setWindowTitle("Dialog")
Dialog.resize(640, 392)
self.verticalLayout = QtGui.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("vertical_layout")
self.tableView = QtGui.QTableView(Dialog)
self.tableView.setObjectName("table_view")
self.verticalLayout.addWidget(self.tableView)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal )
self.buttonBox.setStandardButtons(QtGui.QDialogBut tonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("button_box")
self.verticalLayout.addWidget(self.buttonBox)


QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.test)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.test)
QtCore.QMetaObject.connectSlotsByName(Dialog)

self.open_database()
self.model = QtSql.QSqlTableModel()
self.initializeModel(self.model)
self.tableView.setModel(self.model)
#self.tableView.setItemDelegate(QtSql.QSqlRelation alDelegate(self.tableView))
#self.tableView.hideColumn(0)


def open_database(self):
self._db = QtSql.QSqlDatabase.addDatabase("QMYSQL3")
self._db.setHostName("localhost")
self._db.setUserName("root")
self._db.setPassword("123456")
self._db.setDatabaseName("my_database")
self._db.open()

def initializeModel(self, model):
model.setTable('my_table')

model.setEditStrategy(QtSql.QSqlTableModel.OnManua lSubmit)
model.select()
#model.removeColumn(0)

model.setHeaderData(0, QtCore.Qt.Horizontal, "ID")
model.setHeaderData(1, QtCore.Qt.Horizontal, "First name")
model.setHeaderData(2, QtCore.Qt.Horizontal, "Last name")


def test(self):
ok = self.model.submitAll()
print (self.model.lastError().text())

if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())




Any help would be much appreciated.

Sorry, I have forgotten the error code

This is the output;

Using unsupported buffer type: XX (parameter: XX) QMYSQL3: Unable to bind value

intel04
21st October 2012, 21:13
It is strange. Now I have tested my code on Python 3.3 32 bit and everything works perfect.

The problem was with Python 3.2 64 bit. Both Mysql db is the same. I could not figure out the problem. Not a clue. The code is working fine now.

intel04
29th October 2012, 11:52
I have solved the problem. And I am writing in case it helps someone who faces with similar problems.

The program connects a remote database. And there is another MySQL database installed on my harddrive. I have removed the installed MySQL from my harddrive. And problem solved.