Getting column names from Python DBAPI query results

PEP-249 (&ldquo;Python Database API Specification&rdquo; a.k.a. &ldquo;DBAPI&rdquo;) defines a standard interface for database access in Python, implemented by libraries such as psycopg and PyMySQL. One common task with DBAPI libraries that is not immediately obvious is identifying column names in query results, since fetching from a Cursor returns a sequence of list-like rows. For instance, in…