def sqlinsert(table, row):
    """Generates SQL insert into table ...
    Returns (sql, parameters)

    >>> sqlinsert('mytable', {'field1': 2, 'field2': 'toto'})
    ('insert into mytable (field1, field2) values (%s, %s)', [2, 'toto'])
    >>> sqlinsert('t2', {'id': 1, 'name': 'Toto'})
    ('insert into t2 (id, name) values (%s, %s)', [1, 'Toto'])
    """
    validate_name(table)
    fields = sorted(row.keys())
    validate_names(fields)
    values = [row[field] for field in fields]
    sql = "insert into {} ({}) values ({})".format(
        table, ', '.join(fields), ', '.join(['%s'] * len(fields)))
    return sql, values