[Sqlalchemy-tickets] Issue #4085: Warning 1366 Incorrect string value (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Isaac_Hernandez <iss...@bi...> - 2017-09-20 13:39:03
|
New issue 4085: Warning 1366 Incorrect string value https://bitbucket.org/zzzeek/sqlalchemy/issues/4085/warning-1366-incorrect-string-value Isaac_Hernandez: My code is the next from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, INTEGER, VARCHAR engine = create_engine('mysql://root:Vianney123@localhost:3306/test_sql_alchemy', echo=False) Session = sessionmaker(bind=engine) sesion_db = Session() Base = declarative_base() class Car(Base): __tablename__ = "Cars" Id = Column(INTEGER, primary_key=True) Name = Column(VARCHAR) Price = Column(INTEGER) book = Car(Name='Isaac', Price=5459) sesion_db.add(book) sesion_db.commit() rs = sesion_db.query(Car).all() for car in rs: print(car.Name, car.Price) The SQL of tables is this CREATE TABLE `cars` ( `id` int(10) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Price` int(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 When i'm execute the warning is the next C:\Users\isaac.hernandez\AppData\Local\Programs\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py:504: Warning: (1366, "Incorrect string value: '\\xE9xic' for column 'VARIABLE_VALUE' at row 496") cursor.execute(statement, parameters) I try change the encode to utf8 in create_engine, actually use SQLAlchemy V. 1.1.14 |