Antipattern: Making Bricks Without Straw

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.

Diagnoses Without Diagnostics

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 = ​​ ...

Get SQL Antipatterns, Volume 1 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.