PDA

View Full Version : how can i store and retrieve image from datebase in pyqt programming



pathoo1
10th September 2012, 11:37
imageLabel = QLabel()
m = self.imageLabel.pixmap()
image1= QImage(m)
imageLabel.setPixmap(QPixmap.fromImage(image1))
imageLabel.setScaledContents(True)
imageLabel.setMaximumSize(QSize(115, 112))


#storing the image into database



query = QSqlQuery()



query.prepare("INSERT INTO registration1 ( picture) "
"VALUES (?)")


picture1 = imageLabel

query.addBindValue(picture1)
query.exec_()
QApplication.processEvents()

#query database

print("Calls:")
query.exec_("SELECT id,picture FROM registration1 "
"ORDER by picture")


while query.next():
id = int(query.value(0))
Result_picture = query.value(1)

picture = query.value(4)


print(Result_picture)





imageLabel2 = QLabel()


imageLabel2.setPixmap(QPixmap.fromImage(Result_pic ture))
imageLabel2.setScaledContents(True)
imageLabel2.setMaximumSize(QSize(115, 112))
imageLabel2.show()

QApplication.processEvents()

Hello guys, is there a better way to store and retrieve image file from database in pyqt progrmming?