Inserts data into tables in databases connected via built-in PostgreSQL or SQL Connection.

from morph_lib.database import insert_records

insert_records(
    data: pd.DataFrame,
    table_name: str,
    connection: Optional[str]
) -> None

Supported Databases

  • PostgreSQL

Parameters

data
pd.DataFrame
required

The actual data to pass to the function. The columns specified in primary_keys must exist.

table_name
str
required

Specify the table name.

connection
str

Destination of the connection other than the registered builtin connection (optional)

*If not specified, it will be set to the built-in PostgreSQL.

Example

from morph_lib.database import insert_records

@morph.func
@morph.load_data("user_data")
def func_name(context):
	user_data: pd.DataFrame = context.data["user_data"]
	insert_records(
		insert_data,
		"user",
	)