You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Queries in the current setup returns lists, which can make it confusing concerning which key is which. Using dictionaries, we can avoid confusion during coding (refactoring, doesn't necessarily change anything for the end user).
Right now, querying for the class of a student looks like this.
result=sql_query("SELECT * FROM students WHERE id=0")
print(result[0][4])
The first [0] is the element of the "search query" (which in this case should only consist of one element, as the id should always be unique) and the second [4] refers to the fourth column, which in this case is the class of the student row.
See this StackOverflow question for more information on how to do this.
The text was updated successfully, but these errors were encountered:
Queries in the current setup returns lists, which can make it confusing concerning which key is which. Using dictionaries, we can avoid confusion during coding (refactoring, doesn't necessarily change anything for the end user).
Right now, querying for the
class
of a student looks like this.The first
[0]
is the element of the "search query" (which in this case should only consist of one element, as the id should always be unique) and the second[4]
refers to the fourth column, which in this case is theclass
of the student row.See this StackOverflow question for more information on how to do this.
The text was updated successfully, but these errors were encountered: