From f84f357056b677ab6f23d55196c638583606cc64 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 1 Apr 2020 19:21:41 -0400 Subject: [PATCH] sqlExport: Use `FROM DUAL` in insertDistinct to fix older mariadb --- sqlExport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlExport.py b/sqlExport.py index abb64ee..73efd69 100755 --- a/sqlExport.py +++ b/sqlExport.py @@ -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())}