아미(아름다운미소)

Python PyQt5 QtSql 사용예 본문

랭귀지/python

Python PyQt5 QtSql 사용예

유키공 2018. 12. 14. 09:30

Python PyQt5 QtSql 사용예

#-*- coding: utf-8 -*-
from PyQt5 import QtSql
def run():
    database = QtSql.QSqlDatabase.addDatabase('QSQLITE')
    database.setDatabaseName("analyze.db")
    if not database.open():
        print("Database Error", "Unable To Connect To The Database!")
        stop()
    else:
        print("select")
        query = QtSql.QSqlQuery("SELECT * FROM BPS")
        rec = query.record()
        while query.next():
            for i in range(rec.count()):
                print(query.value(i))

def stop(self):
    self.quit()
    self.wait()

run()

[결과]

PyQt5 QtSql


Comments