From 6a37681dfbec7a4a347286195aa7c50e030ed746 Mon Sep 17 00:00:00 2001 From: Riccardo Vianello Date: Wed, 3 Jan 2024 16:02:36 +0100 Subject: [PATCH] change the handling of autocommit flag to support sqlite3 connections (#7012) fixes #7009 --- rdkit/Dbase/DbUtils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rdkit/Dbase/DbUtils.py b/rdkit/Dbase/DbUtils.py index b37cb6b25c7..d44f32f8cb7 100755 --- a/rdkit/Dbase/DbUtils.py +++ b/rdkit/Dbase/DbUtils.py @@ -355,12 +355,16 @@ def _AddDataToDb(dBase, table, user, password, colDefs, colTypes, data, nullMark block.append(tuple(entries)) if len(block) >= blockSize: nDone += _insertBlock(cn, sqlStr, block) - if not hasattr(cn, 'autocommit') or not cn.autocommit: + # note: in Python 3.12 `cn.autocommit != True` + # is different from `not cn.autocommit` (GH #7009) + if not hasattr(cn, 'autocommit') or cn.autocommit != True: cn.commit() block = [] if len(block): nDone += _insertBlock(cn, sqlStr, block) - if not hasattr(cn, 'autocommit') or not cn.autocommit: + # note: in Python 3.12 `cn.autocommit != True` + # is different from `not cn.autocommit` (GH #7009) + if not hasattr(cn, 'autocommit') or cn.autocommit != True: cn.commit()