D
D
Dmitry2020-05-29 14:52:09
MySQL
Dmitry, 2020-05-29 14:52:09

'_elementunicoderesult' cannot be converted to a MySQL type what to do with it?

OS: Windows Server 2016
Python 3.8

Error code:

sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) Failed processing pyformat-parameters; Python '_elementunicoderesult' cannot be converted to a MySQL type
[SQL: INSERT INTO stiga (`Brand`, `Device`, `Type`, `ParentModel`, `Model`, `SAPCode`, `AssemblyGroup`, `Pos`, `Qty`, `PartNo`, `Description`, `Hint`, `From`, `To`, `ImageURL`, `FileName`) VALUES (%(Brand)s, %(Device)s, %(Type)s, %(ParentModel)s, %(Model)s, %(SAPCode)s, %(AssemblyGroup)s, %(Pos)s, %(Qty)s, %(PartNo)s, %(Description)s, %(Hint)s, %(From)s, %(To)s, %(ImageURL)s, %(FileName)s)]
[parameters: {'Brand': 'STIGA', 'Device': 'Rasenroboter', 'Type': 'Autoclip M Series', 'ParentModel': 'Autoclip M3', 'Model': 'Autoclip M3 (2018)', 'SAPCode': '2R2001508/ST1', 'AssemblyGroup': 'Zubehör', 'Pos': 1, 'Qty': 1, 'PartNo': '1126-9180-01', 'Description': 'Kabel', 'Hint': 'MT 100', 'From': '', 'To': '', 'ImageURL': 'https://stiga.ev-portal.com/Virtual_DataCatalogs/GGP/GGPALL/Ressources/Png/23159.PNG', 'FileName': '2R2001508-ST1.csv'}]


I can’t understand why this error comes out (on some data it comes out, on some it doesn’t). The error occurs only under Windows, under Linux it works fine.

I would be grateful if you could help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-05-30
@LazyTalent

The replacement of the driver for the database helped, ie. It was:

DB_CONNECTION = f'mysql+mysqlconnector://{DB_USER}:{DB_PASSWORD}@localhost/{DB_NAME}'

became:
DB_CONNECTION = f'mysql+pymysql://{DB_USER}:{DB_PASSWORD}@localhost/{DB_NAME}?charset=utf8mb4'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question