def index_exists ( self , table : str , indexname : str ) -> bool : # MySQL: sql = ( "SELECT COUNT(*) FROM information_schema.statistics" " WHERE table_name=? AND index_name=?" ) row = self . fetchone ( sql , table , indexname ) return True if row [ 0 ] >= 1 else False
check if column exists by index python
Does an index exist? ( Specific to MySQL . )
def index_exists(self, table: str, indexname: str) -> bool:
        """Does an index exist? (Specific to MySQL.)"""
        # MySQL:
        sql = ("SELECT COUNT(*) FROM information_schema.statistics"
               " WHERE table_name=? AND index_name=?")
        row = self.fetchone(sql, table, indexname)
        return True if row[0] >= 1 else False