python - SQL Alchemy: SQL syntax error on add with session -


i'm stuck following error when try perform add using session sqlalchemy.

sqlalchemy.exc.programmingerror: (programmingerror) (1064, "you have error in sql syntax; check manual corresponds mysql server version right syntax use near '%s)' @ line 1") b'insert ctr_status (`name`) values (%s)' ('test',)

here code:

from sqlalchemy import metadata, table sqlalchemy import create_engine, orm  # login omitted...  url = 'mysql+mysqldb://{user}:{password}@{host}:{port}/{database}'.format(user=user, password=password, host=host, port=port, database=database) e = create_engine(url, echo=true) metadata = metadata() metadata.bind = e metadata.create_all() ctr_status = table('ctr_status', metadata, autoload=true)  class ctrstatus(object):     pass orm.mapper(ctrstatus, ctr_status) new_status = ctrstatus() new_status.name = 'test'  session_maker = orm.sessionmaker(bind=e, autoflush=true, autocommit=false, expire_on_commit=true) session = orm.scoped_session(session_maker) session.add(new_status)  # crash here @ flush session.flush() 

i'm confused i'm doing wrong. i'm using mysql 5.5, python 3.3.2 , sqlalchemy-0.8.2.win32-py3.3.

here of links have been following:

sql alchemy - tutorial

sql alchemy - sessions

i managed working switching adapter oursql , changing url use mysql+oursql.

i add surprisingly non-trivial oursql working on setup python 3.3.

  1. i had delete oursqlx/oursql.c initial downloaded files such auto-generated cython.
  2. i had manually modify setup.py because pointing wrong registry path mysql_root variable in setup_windowsish(). essentially, current implementation doesn't seem support mysql server 5.5 nor support if registry path in hkey_current_user instead of hkey_local_machine.

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -