insert_list_of_dictionaries_into_database_tables (function)

fundamentals.mysql.insert_list_of_dictionaries_into_database_tables(dbConn, log, dictList, dbTableName, uniqueKeyList=[], dateModified=False, dateCreated=True, batchSize=2500, replace=False, dbSettings=False)[source][source]

insert list of dictionaries into database tables

Key Arguments

  • dbConn – mysql database connection

  • log – logger

  • dictList – list of python dictionaries to add to the database table

  • dbTableName – name of the database table

  • uniqueKeyList – a list of column names to append as a unique constraint on the database

  • dateModified – add the modification date as a column in the database

  • dateCreated – add the created date as a column in the database

  • batchSize – batch the insert commands into batchSize batches

  • replace – replace row if a duplicate is found

  • dbSettings – pass in the database settings so multiprocessing can establish one connection per process (might not be faster)

Return

  • None

Usage

```python from fundamentals.mysql import insert_list_of_dictionaries_into_database_tables insert_list_of_dictionaries_into_database_tables(

dbConn=dbConn, log=log, dictList=dictList, dbTableName=”test_insert_many”, uniqueKeyList=[“col1”, “col3”], dateModified=False, batchSize=2500

)