def _collect_insert_commands(base_mapper, uowtransaction, table,
                             states_to_insert):
    insert = []
    for state, state_dict, mapper, connection, has_identity, \
            instance_key, row_switch in states_to_insert:
        if table not in mapper._pks_by_table:
            continue

        pks = mapper._pks_by_table[table]

        params = {}
        value_params = {}

        has_all_pks = True
        has_all_defaults = True
        for col in mapper._cols_by_table[table]:
            if col is mapper.version_id_col and \
                    mapper.version_id_generator is not False:
                val = mapper.version_id_generator(None)
                params[col.key] = val
            else:
                # pull straight from the dict for
                # pending objects
                prop = mapper._columntoproperty[col]
                value = state_dict.get(prop.key, None)

                if value is None:
                    if col in pks:
                        has_all_pks = False
                    elif col.default is None and \
                            col.server_default is None:
                        params[col.key] = value
                    elif col.server_default is not None and \
                            mapper.base_mapper.eager_defaults:
                        has_all_defaults = False

                elif isinstance(value, sql.ClauseElement):
                    value_params[col] = value
                else:
                    params[col.key] = value

        insert.append((state, state_dict, params, mapper,
                       connection, value_params, has_all_pks,
                       has_all_defaults))
    return insert
Identify sets of values to use in INSERT statements for a
dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py/_collect_insert_commands