Hi,
I'm totally a newbie. I have this project in mind. I want to search data from my database and if it finds it, it will display the selected data to my QTreeView. I have already a query that can connect to my Postgresql Database. Here is the code:
import sys
from PyQt4.QtSql import *
def createConnection():
db = QSqlDatabase.addDatabase("QPSQL");
db.setHostName("localhost")
db.setPort(5432)
db.setDatabaseName("db")
db.setUserName("username")
db.setPassword("password")
ok = db.open()
query = QSqlQuery()
query.exec_("select * from itemlist;")
return True
This is the code for connecting to my database. My table for example is composed of pkey,itemcode,description and Quantity. I have a QLineEdit in my Gui. In that QLineEdit,it will search the ItemCode from my table and when it finds an item, it will automatically send that item data to my QTreeView with its details. How can this be possible. I hope you could help me. Please.
Best Regards,
Nethan
Bookmarks