sqlmapproject/sqlmap · error · SqlmapConnectionException

getSafeExString(ex)

Error message

getSafeExString(ex)

What it means

Error-path record in SQLAlchemyConnector.execute: the message text is literally getSafeExString(ex) — a formatting placeholder that surfaces the caught OperationalError/ProgrammingError/DataError/IntegrityError as a SqlmapConnectionException with its stringified cause.

Solutions

  1. Read the embedded driver error to identify the failing SQL
  2. Fix the query (syntax, missing object, constraint violation)
  3. Verify connection liveness and reconnect if the session dropped
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at lib/utils/sqlalchemy.py:151 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/ed0f92e09b52e134. Report an issue: GitHub.

Appendix: source

Thrown at lib/utils/sqlalchemy.py:151

            # would be silently lost). SELECT goes through select() with commit=False so the result set is
            # fetched BEFORE committing: on some drivers (e.g. pymssql) commit() discards the open cursor, which
            # otherwise made every MSSQL '-d' query silently return empty (banner/is-dba/dump all blank).
            if commit and hasattr(self.connector, "commit"):
                self.connector.commit()
            retVal = True
        except (_sqlalchemy.exc.OperationalError, _sqlalchemy.exc.ProgrammingError, _sqlalchemy.exc.DataError, _sqlalchemy.exc.IntegrityError) as ex:
            logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
            # Roll back the failed statement's transaction so it does not poison every following query with
            # 'InFailedSqlTransaction' (SQLAlchemy 2.0+ keeps the transaction open after an error). Without this
            # a single legitimately-failing probe - e.g. AURORA_VERSION() on vanilla PostgreSQL during
            # fingerprinting - made all later queries silently return wrong values (e.g. '--is-dba' read False)
            if hasattr(self.connector, "rollback"):
                try:
                    self.connector.rollback()
                except Exception:
                    pass
        except _sqlalchemy.exc.InternalError as ex:
            raise SqlmapConnectionException(getSafeExString(ex))

        return retVal

    def select(self, query):
        retVal = None

        # Fetch BEFORE committing (commit=False): committing can discard the open result cursor on some drivers
        # (e.g. pymssql), which silently emptied every MSSQL '-d' result. No DML is persisted by a SELECT anyway.
        if self.execute(query, commit=False):
            retVal = self.fetchall()
            if hasattr(self.connector, "commit"):
                try:
                    self.connector.commit()
                except Exception:
                    pass

        return retVal

View on GitHub (pinned to 0a35b20e39)