askel wrote: > > Hi Mike, > > create_engine(..., paramstyle='qmark') > > has fixed the problem. Is there any DBAPI that treats numbers without > leading semicolon as placeholders? How ebedded integers work then? > > Thank you for quick response and working solution.
the integer thing you saw is a bug. It's fixed in the 0.5 branch and in trunk r6416 r6417. > > Alexander > > On Oct 20, 12:09 pm, "Michael Bayer" <[email protected]> wrote: >> askel wrote: >> >> > Looks like I'm experiencing similar problems with InformixDB 2.5 and >> > SQLAlchemy 0.5.6. Whenever parameters are sent for execution it looks >> > like integers are used instead of placeholders like "?" or ":1". >> >> ah. Hopefully your DBAPi can support qmark parameters - pass >> "paramstyle='qmark'" to your create_engine() statement. >> >> otherwise this would be the patch you want: >> >> Index: lib/sqlalchemy/sql/compiler.py >> =================================================================== >> --- lib/sqlalchemy/sql/compiler.py (revision 6402) >> +++ lib/sqlalchemy/sql/compiler.py (working copy) >> @@ -52,7 +52,7 @@ >> 'pyformat':"%%(%(name)s)s", >> 'qmark':"?", >> 'format':"%%s", >> - 'numeric':"%(position)s", >> + 'numeric':":%(position)s", >> 'named':":%(name)s" >> } >> >> >> >> > Flollowing are some examples: >> >> > 2009-10-20 11:12:46,235 INFO sqlalchemy.engine.base.Engine.0x...f5ac >> > BEGIN >> > 2009-10-20 11:12:46,504 INFO sqlalchemy.engine.base.Engine.0x...f5ac >> > INSERT INTO users (login, password) VALUES (1, 2) >> > 2009-10-20 11:12:46,506 INFO sqlalchemy.engine.base.Engine.0x...f5ac >> > ['bob', None] >> > 2009-10-20 11:12:46,673 INFO sqlalchemy.engine.base.Engine.0x...f5ac >> > ROLLBACK >> > Traceback (most recent call last): >> > File "p.py", line 93, in <module> >> > session.commit() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 673, in commit >> > self.transaction.commit() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 378, in commit >> > self._prepare_impl() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 362, in _prepare_impl >> > self.session.flush() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 1356, in flush >> > self._flush(objects) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 1434, in _flush >> > flush_context.execute() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 261, in execute >> > UOWExecutor().execute(self, tasks) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 753, in execute >> > self.execute_save_steps(trans, task) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 768, in execute_save_steps >> > self.save_objects(trans, task) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 759, in save_objects >> > task.mapper._save_obj(task.polymorphic_tosave_objects, trans) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/mapper.py", line 1406, in _save_obj >> > c = connection.execute(statement.values(value_params), params) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 824, in execute >> > return Connection.executors[c](self, object, multiparams, params) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 874, in _execute_clauseelement >> > return self.__execute_context(context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 896, in __execute_context >> > self._cursor_execute(context.cursor, context.statement, >> > context.parameters[0], context=context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 950, in _cursor_execute >> > self._handle_dbapi_exception(e, statement, parameters, cursor, >> > context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 931, in _handle_dbapi_exception >> > raise exc.DBAPIError.instance(statement, parameters, e, >> > connection_invalidated=is_disconnect) >> > sqlalchemy.exc.InterfaceError: (InterfaceError) too many actual >> > parameters 'INSERT INTO users (login, password) VALUES (1, 2)' ['bob', >> > None] >> >> > =========================================================================== >> > 2009-10-20 11:36:04,640 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > BEGIN >> > 2009-10-20 11:36:04,900 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > INSERT INTO groups (name) VALUES (1) >> > 2009-10-20 11:36:04,901 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > ['admins'] >> > 2009-10-20 11:36:05,166 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > INSERT INTO groups (name) VALUES (1) >> > 2009-10-20 11:36:05,166 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > ['managers'] >> > 2009-10-20 11:36:05,430 INFO sqlalchemy.engine.base.Engine.0x...cfec >> > ROLLBACK >> > Traceback (most recent call last): >> > File "p.py", line 86, in <module> >> > session.commit() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 673, in commit >> > self.transaction.commit() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 378, in commit >> > self._prepare_impl() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 362, in _prepare_impl >> > self.session.flush() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 1356, in flush >> > self._flush(objects) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/session.py", line 1434, in _flush >> > flush_context.execute() >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 261, in execute >> > UOWExecutor().execute(self, tasks) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 753, in execute >> > self.execute_save_steps(trans, task) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 768, in execute_save_steps >> > self.save_objects(trans, task) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/unitofwork.py", line 759, in save_objects >> > task.mapper._save_obj(task.polymorphic_tosave_objects, trans) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/orm/mapper.py", line 1406, in _save_obj >> > c = connection.execute(statement.values(value_params), params) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 824, in execute >> > return Connection.executors[c](self, object, multiparams, params) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 874, in _execute_clauseelement >> > return self.__execute_context(context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 896, in __execute_context >> > self._cursor_execute(context.cursor, context.statement, >> > context.parameters[0], context=context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 950, in _cursor_execute >> > self._handle_dbapi_exception(e, statement, parameters, cursor, >> > context) >> > File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.6-py2.6.egg/ >> > sqlalchemy/engine/base.py", line 931, in _handle_dbapi_exception >> > raise exc.DBAPIError.instance(statement, parameters, e, >> > connection_invalidated=is_disconnect) >> > sqlalchemy.exc.IntegrityError: (IntegrityError) SQLCODE -268 in >> > EXECUTE: >> > 23000: Integrity constraint violation >> > IX000: ISAM error: duplicate value for a record with unique key. >> > 'INSERT INTO groups (name) VALUES (1)' ['managers'] >> >> > I will try previous versions of SQLalchemy to find out when it started >> > to happen. It was working for me previously so it must be some recent >> > version of SQLAlchemy. >> >> > Cheers >> > Alexander >> >> > On Oct 20, 11:28 am, goschtl <[email protected]> wrote: >> >> On 20 Okt., 17:11, "Michael Bayer" <[email protected]> wrote: >> >> >> > goschtl wrote: >> >> >> > > Hello SQLAlchemy, >> >> >> > > i am new to sqlalchemy, i currently work on project which >> >> > > needs sqlalchemy/informix integration. >> >> >> > > Maybe someone can have a look on this: >> >> >> > > >>> session = Session() >> >> > > >>> session >> >> > > <sqlalchemy.orm.session.Session object at ...> >> >> >> > > >>> from sqlalchemy import MetaData >> >> > > >>> metadata = MetaData(session.connection()) >> >> > > >>> metadata >> >> > > MetaData(<sqlalchemy.engine.base.Connection object at ... >> >> >> > > >>> from sqlalchemy import Table >> >> > > >>> users = Table('ln_passwd', metadata, autoload=True) >> >> >> > > >>> print users.c.az == "022301429" >> >> > > ln_passwd.az = 1 <--- i guess this should be >> ln_passwd.az >> >> > > = ? >> >> >> > > >>> print users.insert(az='022301429') >> >> > > INSERT INTO ln_passwd (az, az_key, passwort, berecht, versand, >> >> > > e_m_dat, e_m_zeit, sb_id, ser_nr, s_flag, upd_count) VALUES (1, >> 2, >> >> 3, >> >> > > 4, 5, 6, 7, 8, 9, 10, 11) >> >> >> > you mean to say: >> >> >> > insert().values(az='022301429') >> >> >> Hi Michael, >> >> >> you are right this seems to work... thanks for that? >> >> >> > also the informix dialect to my knowledge has never been used in >> >> recent >> >> > versions of SQLAlchemy, so your results may vary. at the moment >> its >> >> > entirely unsupported since it lacks a maintainer. >> >> >> Any idae where i can look for this error: >> >> >> >>> print users.c.az == "022301429" >> >> >> ln_passwd.az = 1 >> >> >> Do you think thats a problem of the driver or the >> >> dialect in >> >> ... >> >> read more » > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
