Skip to content

Resolve "new_data_fileF raises TypeError"

Ivo Hanák requested to merge 37-new_data_filef-raises-typeerror into master

Closes #37 (closed)

Problem

new_data_fileF() raises TypeError in

File ".../pyCDB/pyCDBBase.py", line 803, in mysql_str
    res = "'" + res + "'"

Analysis

CDB is able to use various DB modules to access the database. When it searches for an available DB module, it retrieves the function escape_string(). This function is used to escape strings while building an SQL query using mysql_values(). There, it expects that escape_string() will return an instance of str. However, in case of the supported moduleMySQLdb, escape_string() returns bytes rather than str.

Solution

  1. This fix adds a wrapper which ensures that escape_string() returns str.

  2. This fix adds a minimal fix which allows to test the fix using the module MySQLdb of mysqlclient 2.2.4.

Test

  • This fix was tested by running the unit test with installed pymysql.
  • This fix was tested by running the unit test with installed mysqlclient 2.x.
  • This fix was tested by running new_data_fileF with installed mysqlclient 1.x (codac3).
Edited by Ivo Hanák

Merge request reports

Loading