'Return the identifier quoted in SQL syntax if needed (eg table and column names)'

def _fmt_sql_identifier(self, v):

    if (not len(v)):
        return '""'
    nonalnum = re.sub('[A-Za-z_0-9]+', '', v)
    if (len(nonalnum) == 0):
        if (v.upper() not in self._sqlite_reserved):
            if (v[0] not in '0123456789'):
                return v
    if ('"' in nonalnum):
        return ('[%s]' % (v,))
    return ('"%s"' % (v,))
