Displaying rows in the specified database table
In this recipe, we will be learning to fetch rows from a given database table and display them in tabular format via the Table
widget. We assume a table called Users
consisting of two columns, EmailAddress
and Password
, already exists in a database called ECommerce
. Also, we assume that the Users
table contains some rows in it.
How to do it…
Follow this step-by-step procedure to access rows from the database table in SQLite:
- Let's create an application based on the
Dialog without Buttons
template. - Add three
QLabel
widgets, twoQLineEdit
widgets, oneÂQPushButton
, and oneÂQTableWidget
widget to the form by dragging and dropping threeLabel
widgets, twoLine Edit
widgets, oneÂPush Button
widget, and aTable
widget on the form. - Set the
text
property of the twoLabel
widgets toEnter database name
andEnter table name
. - Delete the
text
property of the thirdLabel
widget because itstext
property will be set through code. - Set the
text
property of the push...