开发者

Python 3, SQLAlchemy, MySQL. Incorrect syntax in INSERT statement

Engine = create_engine("mysql+mysqldb://blah-blah-blah", encoding="utf-8")
Session = sessionmaker(bind = Engine)
ses = Session()
Meta = MetaData(bind = Engine, reflect = True)
PersonTable = Meta.tables["person"]

class Person(object):
   pass

mapper(Person, PersonTable)
APerson = Person("1111", "2222", "1.01.1980")
ses.add(APerson)
ses.commit()

sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s, %s, %s)' at line 1") b'INSERT INTO person (Name, O开发者_如何转开发riginalName, DoB) VALUES (%s, %s, %s)' ('1111', '2222', '25.01.1980')

What is the %s? What do I wrong?

Python 3.1 SQLAlchemy 0.6.5 MySQL 5.1 Windows 7 Ultimate

Thank you.


You sqlalchemy commit is trying to issue an insert query that is not compatible with the schema. near '%s, %s, %s)' means your trying to insert invalid data. I can only speculate that it is because the date format - this is not the proper mysql date format YYYY-MM-DD.


I migrated back to Python 2.7. Now it works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜