> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emtelligent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emtelligent.com/_mcp/server.

# db.schemas.insert

This module contains functions that help with inserting the appropriate number
of rows in various database types.

## Module Contents

### Functions

| Name                                                                                             | Description                                                                                                                       |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| [`exec_returning_id`](#emtelliprodbschemasinsertexec_returning_id)                               |                                                                                                                                   |
| [`exec_insert`](#emtelliprodbschemasinsertexec_insert)                                           | Execute INSERT statements for the given table, using the provided values.                                                         |
| [`exec_insert_default_returning_id`](#emtelliprodbschemasinsertexec_insert_default_returning_id) | For these tables, there are no columns other than the ID, so we have no values to insert.                                         |
| [`duckdb_caching_connection`](#emtelliprodbschemasinsertduckdb_caching_connection)               |                                                                                                                                   |
| [`snowflake_caching_connection`](#emtelliprodbschemasinsertsnowflake_caching_connection)         | Context manager that will return a new connection that caches to a directory and will quickly store to Snowflake using COPY INTO. |

### Data

`logger`
`__all__`

### API

#### `emtellipro.db.schemas.insert.logger`

```python
emtellipro.db.schemas.insert.logger
```

**Value**: `getLogger(...)`

#### `emtellipro.db.schemas.insert.__all__`

```python
emtellipro.db.schemas.insert.__all__
```

**Value**: `['exec_insert', 'exec_insert_default_returning_id', 'exec_returning_id', 'duckdb_caching_connection', 'snowflake_caching_connection']`

#### `emtellipro.db.schemas.insert.exec_returning_id`

```python
emtellipro.db.schemas.insert.exec_returning_id(
    conn,
    cls,
    values
)
```

#### `emtellipro.db.schemas.insert.exec_insert`

```python
emtellipro.db.schemas.insert.exec_insert(
    conn,
    cls,
    values,
    fill_in_defaults = False
)
```

Execute INSERT statements for the given table, using the provided values.

**Parameters:**

**`conn`**

SQLAlchemy Connection object

---

**`cls`**

The Model class representing the table to insert into

---

**`values`**

list of dictionaries containing the values to be
inserted; these must all have the same set of keys, unless
`fill_in_defaults` is enabled.

---

**`fill_in_defaults`**

if True, fill in None for missing keys in
`values`. When inserting multiple values, they must all have the
same set of keys to match the list of columns in the INSERT; if
values come from variable JSON objects, this constraint may not
hold, so you can use this parameter to add the missing keys with
values of None.

---

#### `emtellipro.db.schemas.insert.exec_insert_default_returning_id`

```python
emtellipro.db.schemas.insert.exec_insert_default_returning_id(
    conn, cls
)
```

For these tables, there are no columns other than the ID, so we have no
values to insert.

#### `emtellipro.db.schemas.insert.duckdb_caching_connection`

```python
emtellipro.db.schemas.insert.duckdb_caching_connection(
    duckdb_conn, insert_or_ignore = ()
)
```

#### `emtellipro.db.schemas.insert.snowflake_caching_connection`

```python
emtellipro.db.schemas.insert.snowflake_caching_connection(
    snowflake_conn,
    cache_dir: pathlib.Path,
    tables: collections.abc.Iterable[str]
)
```

Context manager that will return a new connection that caches to a
directory and will quickly store to Snowflake using COPY INTO.