Difference between revisions of "User/Alvonruff/2to3"
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
* The new connector has no support for db.escape_string(). Since mysql.connector is DB API v2.0 compliant, you the API should automatically perform the escape without asking. | * The new connector has no support for db.escape_string(). Since mysql.connector is DB API v2.0 compliant, you the API should automatically perform the escape without asking. | ||
− | * The following code generates the integer 110 on python2, and the float 112.0 on python3. This obviously breaks the ISBN checksum calculator: | + | * The following code generates the integer 110 on python2, and the float 112.0 on python3. Under python3. the division operator in always returns a float. This obviously breaks the ISBN checksum calculator: |
checksum = 112 | checksum = 112 | ||
remainder = (checksum/10)*10 | remainder = (checksum/10)*10 |
Revision as of 15:38, 24 April 2023
- Use 2to3 in a manner the same as futurize. This produces results suitable for python3.
- Update to the official MySQL User:Alvonruff/mysql.connector. There is no python3 support for MySQLdb, which is our current connector. Moving to a new connector is a prerequisite.
- Use of md5 needs to be replaced with hashlib
- Records that return DATETIME fields cannot simply be indexed - they must use built-in datetime methods:
- year = field.year
- month = field.month
- day = field.day
- String operator usage:
- string.replace() must be changed to str.replace()
- string.strip() must be changed to str.strip()
- The new connector has no support for db.escape_string(). Since mysql.connector is DB API v2.0 compliant, you the API should automatically perform the escape without asking.
- The following code generates the integer 110 on python2, and the float 112.0 on python3. Under python3. the division operator in always returns a float. This obviously breaks the ISBN checksum calculator:
checksum = 112 remainder = (checksum/10)*10