text stringlengths 0 828 |
|---|
dbTableName=dbTableName, |
uniqueKeyList=uniqueKeyList, |
dateModified=dateModified, |
returnInsertOnly=True, |
replace=replace, |
reDatetime=reDate, |
skipChecks=True |
) |
theseInserts.append(valueTuple) |
message = """" |
# log.debug('adding new data to the %s table; query: %s' % |
# (dbTableName, addValue)) |
message = writequery( |
log=log, |
sqlQuery=insertCommand, |
dbConn=dbConn, |
Force=True, |
manyValueList=theseInserts |
) |
if message == ""unknown column"": |
for aDict in batch: |
convert_dictionary_to_mysql_table( |
dbConn=dbConn, |
log=log, |
dictionary=aDict, |
dbTableName=dbTableName, |
uniqueKeyList=uniqueKeyList, |
dateModified=dateModified, |
reDatetime=reDate, |
replace=replace |
) |
else: |
inserted = True |
dbConn.commit() |
log.debug('completed the ``_insert_single_batch_into_database`` function') |
return ""None""" |
3977,"def _add_dictlist_to_database_via_load_in_file( |
masterListIndex, |
log, |
dbTablename, |
dbSettings, |
dateModified=False): |
""""""*load a list of dictionaries into a database table with load data infile* |
**Key Arguments:** |
- ``masterListIndex`` -- the index of the sharedList of dictionary lists to process |
- ``dbTablename`` -- the name of the database table to add the list to |
- ``dbSettings`` -- the dictionary of database settings |
- ``log`` -- logger |
- ``dateModified`` -- add a dateModified stamp with an updated flag to rows? |
**Return:** |
- None |
**Usage:** |
.. todo:: |
add usage info |
create a sublime snippet for usage |
.. code-block:: python |
usage code |
"""""" |
log.debug('starting the ``_add_dictlist_to_database_via_load_in_file`` function') |
global sharedList |
dictList = sharedList[masterListIndex][0] |
count = sharedList[masterListIndex][1] |
if count > totalCount: |
count = totalCount |
ltotalCount = totalCount |
# SETUP ALL DATABASE CONNECTIONS |
dbConn = database( |
log=log, |
dbSettings=dbSettings |
).connect() |
now = datetime.now() |
tmpTable = now.strftime(""tmp_%Y%m%dt%H%M%S%f"") |
# CREATE A TEMPORY TABLE TO ADD DATA TO |
sqlQuery = """"""CREATE TEMPORARY TABLE %(tmpTable)s SELECT * FROM %(dbTablename)s WHERE 1=0;"""""" % locals() |
writequery( |
log=log, |
sqlQuery=sqlQuery, |
dbConn=dbConn |
) |
csvColumns = [k for d in dictList for k in d.keys()] |
csvColumns = list(set(csvColumns)) |
csvColumnsString = (', ').join(csvColumns) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.