Hallo again,
now I have to handle pictures. In a SQLite database I would like to save
pictures from people. So I made a table
CREATE table pictures (id integer, pic blob)
With PyQT4 I build a formular where I want to show the pictures. (In
fact the formular shows data from a person, and even a picture of a
person.) I use a QtGui.QLabel as the widget, which takes alternativly
text or a pixmap. The workflow is:
1. Get the picture from a file, let's say pic.jpg, an show it in the
label. That is done by
pic = QtGui.QPixmap("pic.jpg")...
Label.setPixmap(pic) # a method of the QtLabel.
That works, the picture is shown.
2. Store the picture in the database. I tried
pixmap = Label.getPixmap()
sql = "INSERT into pictures (pic) values (?)"
cursor.execute(sql, (pixmap,))
That doesn't work, it ends with "TypeError: Bad binding argument type
supplied - argument #2: type QPixmap".
3. Get the picture back from the database. It should be something like
sql = "SELECT pic from pictures"
pixmap = cursor.execute(sql)... # yes, I know, that doesn't work,
# but in a way we get pixmap set to
# the pic column from some row
Label.setPixmap(pixmap)
As You can see, the second step doesn't work, for the third I don't have
any idea. It seems to be a problem of type-conversion betwenn blob
(SQLite) and QPixmap (Qt, python) in both directions.
By the way: Even Qt has a QtSql module, but for the moment I prefere to
use the apsw module...
Every hint is welcome!
Ulrich
--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users