October 2022
Intermediate to advanced
380 pages
9h 35m
English
Developers commonly practice the See No Evil antipattern in two forms: first, ignoring the return values of a database API, and second, reading fragments of SQL code interspersed with application code. In both cases, developers fail to use information that is easily available to them.
The following code example contains errors, but no error checking.
| | import mysql.connector |
| | |
| ① | cnx = mysql.connector.connect(user='scottt', database='test') |
| | |
| | cursor = cnx.cursor() |
| | |
| | query = '''SELCET bug_id, summary, date_reported FROM Bugs |
| | WHERE assigned_to = %s AND status = %s''' |
| | |
| | parameters = (1, 'NEW') |
| | |
| ② | cursor.execute(query, ... |