insert_list_of_dictionaries_into_database_tables (function) ∞
-
insert_list_of_dictionaries_into_database_tables
(dbConn, log, dictList, dbTableName, uniqueKeyList=[], dateModified=False, dateCreated=True, batchSize=2500, replace=False, dbSettings=False)[source] ∞ insert list of dictionaries into database tables
Key Arguments
dbConn
– mysql database connectionlog
– loggerdictList
– list of python dictionaries to add to the database tabledbTableName
– name of the database tableuniqueKeyList
– a list of column names to append as a unique constraint on the databasedateModified
– add the modification date as a column in the databasedateCreated
– add the created date as a column in the databasebatchSize
– batch the insert commands into batchSize batchesreplace
– repalce row if a duplicate is founddbSettings
– pass in the database settings so multiprocessing can establish one connection per process (might not be faster)
Return
None
Usage
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 )