sqlExport: Use FROM DUAL in insertDistinct to fix older mariadb

This commit is contained in:
Adam Goldsmith 2020-04-01 19:21:41 -04:00
parent bdf3b84c74
commit f84f357056

View File

@ -32,7 +32,7 @@ def insertDistinctFromTableMap(table, data, tableMap):
# TODO: this could probably be done better as a single statement?
c.executemany(
f"""INSERT INTO {table} ({','.join(f'`{k}`' for k in tableMap.keys())})
SELECT {','.join(len(tableMap) * ['%s'])}
SELECT {','.join(len(tableMap) * ['%s'])} FROM DUAL
WHERE NOT EXISTS (
SELECT 1 from {table}
WHERE {' AND '.join(f'`{k}`<=>%s' for k in tableMap.keys())}