/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
sqlite3__examples/append_image/main.py
49 строк
914 B
gil9red
Refactoring. Using black code style
27 июн 2023, 13:10
27 июн 2023, 13:10
4c3d759
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import sys import sqlite3 from PyQt5.QtWidgets import * from PyQt5.QtGui import * if __name__ == "__main__": con = sqlite3.connect("test.sqlite") cur = con.cursor() cur.execute( """ CREATE TABLE IF NOT EXISTS Images ( Data BLOB ) """ ) con.commit() with open("capture.png", mode="rb") as f: binary = sqlite3.Binary(f.read()) cur.execute("INSERT INTO Images(Data) VALUES (?)", (binary,)) con.commit() app = QApplication([]) w = QWidget() layout = QVBoxLayout() w.setLayout(layout) for (img_data,) in con.execute("SELECT Data from Images"): pixmap = QPixmap() pixmap.loadFromData(img_data) label = QLabel() label.setPixmap(pixmap) layout.addWidget(label) w.show() sys.exit(app.exec_())