Hi Alexander, Hi Michael,

thanks to you both for your quick help.

create_engine(..., paramstyle='qmark')

With the paramstyle='qmark' it works like a charm.

Christian

On 20 Okt., 18:23, askel <[email protected]> wrote:
> Michael,
>
> I'm sorry for calling you Mike. There is admin Mike that was giving me
> hard time all this morning and I have been writing to him alot
> recently.
>
> Cheers
> Alexander
>
> On Oct 20, 12:18 pm, askel <[email protected]> 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.
>
> > 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()
> > > >> > >    >>>
>
> ...
>
> Erfahren Sie mehr »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to