Resolve "new_data_fileF raises TypeError"
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
-
This fix adds a wrapper which ensures that
escape_string()returnsstr. -
This fix adds a minimal fix which allows to test the fix using the module
MySQLdbof 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_fileFwith installed mysqlclient 1.x (codac3).
Edited by Ivo Hanák