From f05c3b6ff75832b2da2690c92b6c5fb12e700be8 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 5 Mar 2026 17:07:37 +0100 Subject: Improve debug messages for ExecuteSQL() calls. --- import_source.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/import_source.py b/import_source.py index 289bc4c..3b187a5 100644 --- a/import_source.py +++ b/import_source.py @@ -405,7 +405,9 @@ def clearLayer(lyr : ogr.Layer) -> None: op = 'Clearing' logging.info('%s table %s (former feature count: %s)', op, lyr.GetName(), str(n) if n >= 0 else 'unknown') - ds.ExecuteSQL(query.format(table=getEscapedTableName(lyr))) + query = query.format(table=getEscapedTableName(lyr)) + logging.debug('ExecuteSQL(%s)', query) + ds.ExecuteSQL(query) def extractArchive(path : Path, destdir : str, fmt : str|None = None, @@ -489,7 +491,7 @@ def importSources(lyr : ogr.Layer, if dsoTransaction: # declare a SAVEPOINT (nested transaction) within the DS-level transaction lyrTransaction = 'SAVEPOINT ' + escape_identifier('savept_' + layername) - logging.debug('%s', lyrTransaction) + logging.debug('ExecuteSQL(%s)', lyrTransaction) dso.ExecuteSQL(lyrTransaction) elif lyr.TestCapability(ogr.OLCTransactions): # try to start transaction on the layer @@ -536,7 +538,7 @@ def importSources(lyr : ogr.Layer, rv = ImportStatus.IMPORT_ERROR if isinstance(lyrTransaction, str): query = 'ROLLBACK TO ' + lyrTransaction - logging.exception('Exception occured within transaction: %s', query) + logging.exception('Exception occured within transaction. ExecuteSQL(%s)', query) # don't unset lyrTransaction here as we want to RELEASE SAVEPOINT try: dso.ExecuteSQL(query) @@ -557,7 +559,7 @@ def importSources(lyr : ogr.Layer, finally: if isinstance(lyrTransaction, str): query = 'RELEASE ' + lyrTransaction - logging.debug('%s', query) + logging.debug('ExecuteSQL(%s)', query) try: dso.ExecuteSQL(query) except Exception: # pylint: disable=broad-exception-caught @@ -981,7 +983,7 @@ def updateLayerCache(lyr : ogr.Layer, cache : ogr.Layer, query += ' ORDER BY ' + ','.join(['t.' + escape_identifier(c) for c in sort_by]) struct_dgst : Final = struct.Struct('@qq').pack - logging.debug('%s', query) + logging.debug('ExecuteSQL(%s)', query) ds = lyr.GetDataset() with ds.ExecuteSQL(query) as lyr2: defn2 = lyr2.GetLayerDefn() @@ -1050,7 +1052,7 @@ def updateLayerCache(lyr : ogr.Layer, cache : ogr.Layer, logging.info('Updated layer "%s" has identical fingerprint %s, rolling back', layername, fingerprint.hex()[:8]) query = 'ROLLBACK TO ' + lyrTransaction - logging.debug('%s', query) + logging.debug('ExecuteSQL(%s)', query) try: ds.ExecuteSQL(query) except Exception: # pylint: disable=broad-exception-caught -- cgit v1.2.3