January 2019
Beginner
556 pages
14h 19m
English
When a query that returns a dataset is executed in a cursor, this data can be made available in the application. This is not only about SELECT queries, but also any data-changing query that has a RETURNING clause.
Suppose there is a cursor that has executed a query, as follows:
cur = conn.cursor()cur.execute("SELECT make, model FROM car_portal_app.car_model")
The cursor object provides several ways to retrieve the data:
for record in cur: print("Make: {}, model: {}".format(record[0], record[1]))
Here, record is a tuple and the values of the fields can be accessed using the square-bracket syntax, specifying the number of the field (zero-based).
Read now
Unlock full access