Skip to content

docker-tests are failing with Python3.7 #589

@mauriciovasquezbernal

Description

@mauriciovasquezbernal

When running tox -e docker-tests I got a failure in one of the tests mysql/test_mysql_functional.py::TestFunctionalMysql::test_executemany FAILED [ 30%].

This is the output that failure:

========================================= FAILURES ==========================================
___________________________ TestFunctionalMysql.test_executemany ____________________________

self = <test_mysql_functional.TestFunctionalMysql testMethod=test_executemany>

    def test_executemany(self):
        """Should create a child span for executemany
        """
        with self._tracer.start_as_current_span("rootSpan"):
            data = ["1", "2", "3"]
            stmt = "INSERT INTO test (id) VALUES (%s)"
>           self._cursor.executemany(stmt, data)

mysql/test_mysql_functional.py:98: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../opentelemetry-ext-dbapi/src/opentelemetry/ext/dbapi/__init__.py:245: in executemany
    self.__wrapped__.executemany, *args, **kwargs
../../opentelemetry-ext-dbapi/src/opentelemetry/ext/dbapi/__init__.py:221: in traced_execution
    raise ex
../../opentelemetry-ext-dbapi/src/opentelemetry/ext/dbapi/__init__.py:216: in traced_execution
    result = query_method(*args, **kwargs)
../../../.tox/docker-tests/lib/python3.7/site-packages/mysql/connector/cursor_cext.py:350: in executemany
    stmt = self._batch_insert(operation, seq_params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <mysql.connector.cursor_cext.CMySQLCursor object at 0x7fbcd5f7c290>
operation = 'INSERT INTO test (id) VALUES (%s)', seq_params = ['1', '2', '3']

    def _batch_insert(self, operation, seq_params):
        """Implements multi row insert"""
        def remove_comments(match):
            """Remove comments from INSERT statements.
    
            This function is used while removing comments from INSERT
            statements. If the matched string is a comment not enclosed
            by quotes, it returns an empty string, else the string itself.
            """
            if match.group(1):
                return ""
            return match.group(2)
    
        tmp = re.sub(RE_SQL_ON_DUPLICATE, '',
                     re.sub(RE_SQL_COMMENT, remove_comments, operation))
    
        matches = re.search(RE_SQL_INSERT_VALUES, tmp)
        if not matches:
            raise errors.InterfaceError(
                "Failed rewriting statement for multi-row INSERT. "
                "Check SQL syntax."
            )
        fmt = matches.group(1).encode(self._cnx.python_charset)
        values = []
    
        try:
            stmt = operation.encode(self._cnx.python_charset)
            for params in seq_params:
                tmp = fmt
                prepared = self._cnx.prepare_for_mysql(params)
                if isinstance(prepared, dict):
                    for key, value in prepared.items():
                        tmp = tmp.replace("%({0})s".format(key).encode(), value)
                elif isinstance(prepared, (list, tuple)):
                    psub = _ParamSubstitutor(prepared)
                    tmp = RE_PY_PARAM.sub(psub, tmp)
                    if psub.remaining != 0:
                        raise errors.ProgrammingError(
                            "Not all parameters were used in the SQL statement")
                values.append(tmp)
    
            if fmt in stmt:
                stmt = stmt.replace(fmt, b','.join(values), 1)
                self._executed = stmt
                return stmt
            return None
        except (UnicodeDecodeError, UnicodeEncodeError) as err:
            raise errors.ProgrammingError(str(err))
        except Exception as err:
            raise errors.InterfaceError(
>               "Failed executing the operation; %s" % err)
E           mysql.connector.errors.InterfaceError: Failed executing the operation; Could not process parameters

../../../.tox/docker-tests/lib/python3.7/site-packages/mysql/connector/cursor_cext.py:329: InterfaceError

This is some information of the versions I'm using:

$ python --version
Python 3.7.4
$ tox --version
3.14.6 imported from /home/mvb/virtualenvs/otel-python-3.7/lib/python3.7/site-packages/tox/__init__.py

I have the API, SDK and different integrations installed from b62c233.

I tested with @codeboten and he has the same failure on that Python version, with Python3.8 it works fine for him.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions