Red Pandas Module¶
alyeska redpandas module for smoother pandas/redshift functionality
-
alyeska.redpandas.
assert_table_exists
(cnxn: psycopg2.extensions.connection, schema: str, table: str) → None¶ Check that the table actually exists
Parameters: - cnxn (psycopg2.extensions.connection) – [description]
- schema (str) – [description]
- table (str) – [description]
Raises: MissingTableError
– If the target schema.table does not exist
-
alyeska.redpandas.
generate_insert_queries
(curs: psycopg2.extensions.cursor, insert_table: str, df: pandas.core.frame.DataFrame, *, chunksize: int = 10000) → Coroutine[T_co, T_contra, V_co]¶ Generator that helps insert_pandas_into. Assumes totally valid arguments, and colnames must match the schema of the insert table.
Parameters: - curs (psycopg2.extensions.cursor) – Connection used to insert to table
- insert_table (str) – Target table in database
- df (pd.DataFrame) – Pandas dataframe that will be inserted
- chunksize (int, optional) – How many rows to write per insert. Defaults to 10000.
Returns: None
-
alyeska.redpandas.
insert_pandas_into
(cnxn: psycopg2.extensions.connection, insert_table: str, df: pandas.core.frame.DataFrame, *, chunksize: int = 10000) → None¶ Open connection and insert df into insert_table.
Parameters: - cnxn (psycopg2.extensions.connection) – Connection used to insert to table
- insert_table (str) – Target table in database
- df (pd.DataFrame) – Pandas dataframe that will be inserted
- chunksize (int, optional) – How many rows to write per insert. Defaults to 10000.
Returns: [description]
Return type: None