db.schemas.insert

emtellipro.db.schemas.insert

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

Module Contents

Functions

NameDescription
exec_returning_id
exec_insertExecute INSERT statements for the given table, using the provided values.
exec_insert_default_returning_idFor these tables, there are no columns other than the ID, so we have no values to insert.
duckdb_caching_connection
snowflake_caching_connectionContext 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

emtellipro.db.schemas.insert.logger

Value: getLogger(...)

emtellipro.db.schemas.insert.__all__

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

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

emtellipro.db.schemas.insert.exec_insert

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

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

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

emtellipro.db.schemas.insert.snowflake_caching_connection

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.