dr_data.inject package

Module contents

class dr_data.inject.Inject(schema, configuration)[source]

Bases: object

Inserts one or many randomly regenerated rows

build_dataframe(columns)[source]

Creates panda dataframe from the list of table columns :param columns: name of the column :type columns: list[str] :return: Panda DataFrame :rtype: DataFrame

execute_cmd(how_many)[source]

Executes the insert command, main entry point :param how_many: How many rows to insert :type how_many: int :return: None :rtype: None

get_random_row(columns, table)[source]

Gets a random row from a table :param columns: The columns of a table :type columns: dict :param table: The name of the table :type table: str :return: Random row from the database :rtype: dict

get_random_row_where(columns, table, query)[source]

Gets a random row from a table where something equals something. :param columns: The columns of a table :type columns: dict :param table: The name of the table :type table: str :param query: The execution query :type query: str :return: Random row from the database :rtype: dict

insert_table_data(index: int, query: str, conn: psycopg2.extensions.connection, cur: psycopg2.extensions.cursor, df: pandas.core.frame.DataFrame, page_size: int) None[source]

Insert table data :param index: index to start :type index: int :param query: The query to run :type query: str :param conn: database connection :type conn: dict :param cur: database cursor :type cur: dict :param df: The dataframe that will be inserted :type df: Dataframe :param page_size: The size of the database page :type page_size: int :return: None :rtype: None

populate_table(how_many, table_name, columns_data)[source]

Inserts all table data into the database :param how_many: The amount of rows to insert :type how_many: int :param table_name: The name of the table :type table_name: str :param columns_data: The column meta data :type columns_data: dict :return: None :rtype: None

set_data_by_type(column)[source]

This sets the value (or data) by the column type :param column: column dictionary :type column: dict :return: value of type :rtype: Any