baztian / jaydebeapi

JayDeBeApi module allows you to connect from Python code to databases using Java JDBC. It provides a Python DB-API v2.0 to that database.
GNU Lesser General Public License v3.0
365 stars 148 forks source link

check if autocommit is enabled for the database, and skip commit if 'yes' #208

Open mloyanich opened 2 years ago

mloyanich commented 2 years ago

PorstgreSQL database throws an error, when you try calling commit() when the autocommit is enabled: sqlalchemy.exc.DatabaseError: (jaydebeapi.DatabaseError) org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.

Regular psycopg2 driver ignores the commit if there is nothing to commit (which would be true in case transactions were autocommited)

Could we add the functionality to skip commit in case jconn.getAutoCommit() == True?