def get_constraints(cursor, table_name):
constraints = {}<EOL>cursor.execute("""<STR_LIT>""", [table_name])<EOL>for constraint, column, kind, used_cols in cursor.fetchall():<EOL><INDENT>if constraint not in constraints:<EOL><INDENT>constraints[constraint] = {<EOL>"<STR_LIT>": [],<EOL>"<STR_LIT:primary_key>": kind.lower() == "<STR_LIT>",<EOL>"<STR_LIT>": kind.lower() in ["<STR_LIT>", "<STR_LIT>"],<EOL>"<STR_LIT>": tuple(used_cols[<NUM_LIT:0>].split("<STR_LIT:.>", <NUM_LIT:1>)) if kind.lower() == "<STR_LIT>" else None,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT:index>": False,<EOL>}<EOL><DEDENT>constraints[constraint]['<STR_LIT>'].append(column)<EOL><DEDENT>cursor.execute("""<STR_LIT>""", [table_name])<EOL>for constraint, column in cursor.fetchall():<EOL><INDENT>if constraint not in constraints:<EOL><INDENT>constraints[constraint] = {<EOL>"<STR_LIT>": [],<EOL>"<STR_LIT:primary_key>": False,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT:index>": False,<EOL>}<EOL><DEDENT>constraints[constraint]['<STR_LIT>'].append(column)<EOL><DEDENT>cursor.execute("""<STR_LIT>""", [table_name])<EOL>for index, columns, unique, primary in cursor.fetchall():<EOL><INDENT>if index not in constraints:<EOL><INDENT>constraints[index] = {<EOL>"<STR_LIT>": list(columns),<EOL>"<STR_LIT:primary_key>": primary,<EOL>"<STR_LIT>": unique,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT:index>": True,<EOL>}<EOL><DEDENT><DEDENT>return constraints<EOL>
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.