I'm starting my Computing project and am using Python linked via sqlite3 to a database. As part of my project I shall be searching for maths books in the database via name or module etc. I wish to display the results on a GUI in python so need to set variables to the results depending on the amount of results. I assume an list with a for loop setting each value in the list as a id of a book and then retrieving data via the id would work but I don't know how to set the results as the ID.

Would it be anything like (Pseudo Code)

for rows in database:
    *if row matches search criteria*
        list[nextFree] = rows[count].ID
        nextFree = nextFree + 1 
    count = count + 1 

Please help!!!

It is not exactly the scheme. In python there is a DB-API, which many database modules, like sqlite3, try to implement. What this api says in short, si that the pseudo code looks like

create a Connection object (using the db file name)
create a Cursor object for this connection
execute a (SQL) query, using cursor.execute()
for row in cursor:
    do something with the row
close cursor
close connection

See the example with a SELECT * sql request in the module documentation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.