0
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, OriginalName, 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.

2
  • its a C-style print thing, where each %s is supposed to sub for the string values '1111', '222' and '25.01.1980' respectively. I don't know sqlalchemy in order to help you fix this Commented Nov 18, 2010 at 14:11
  • here is a similar question although more recent, hopefully it will have a useful answer: stackoverflow.com/questions/14732533/… Commented Feb 6, 2013 at 16:33

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I removed columb "DoB", but it did not help. The same error. CREATE TABLE Person( ID INT(11) NOT NULL AUTO_INCREMENT, Name VARCHAR(255) NOT NULL, OriginalName VARCHAR(255), PRIMARY KEY (ID) ) ENGINE=InnoDB;
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.