[PyQt] [SOLVED]Syntax to access a blob column on sqlite

IloChab ilochab at gmail.com
Mon Mar 29 14:36:59 BST 2010


2010/3/28 IloChab <ilochab at gmail.com>:
> I tried in this way:
>
> blobField = QtCore.QVariant ( QtCore.QByteArray ([1,2,3,]) )
> query = QtSql.QSqlQuery()
> query.prepare("""INSERT INTO blobTable (blobColumn) VALUES(?)""")
> query.bindValue(0,(blobField,));
> query.exec_();
>
>
> ... and I got no error, but in the DB I find an empty field: (u'')
>
>
> Which is the correct syntax to store a blob field???
>



The right way to do it was:


blobField = QtCore.QByteArray ([1,2,3,])
query = QtSql.QSqlQuery()
query.prepare("""INSERT INTO blobTable (blobColumn) VALUES(?)""")
query.bindValue(0,  QtCore.QByteArray(blobField,))
query.exec_()


I hope this can be usefull to someone else!!

Thank to the list anyway!


More information about the PyQt mailing list