More robust quoting of database identifiers

Note: These aren't database values, those are already using the
appropriate Pyhton DB API method for quoting.