Insert multiple fails with mssql

Issue #173 resolved
Former user created an issue

I tried to run firststeps.py from Robin Munn's tutorial using mssql as the database. It fails on the line

i.execute({'name': 'John', 'age': 42},
          {'name': 'Susan', 'age': 57},
          {'name': 'Carl', 'age': 33})

with this traceback

Traceback (most recent call last):
  File "D:\Misc\Python\firststeps.py", line 20, in ?
    {'name': 'Carl', 'age': 33})
  File "C:\Python24\lib\site-packages\sqlalchemy\sql.py", line 472, in execute
    return self.using(self.engine).execute(*multiparams, **params)
  File "C:\Python24\lib\site-packages\sqlalchemy\sql.py", line 377, in execute
    return self.compile(*multiparams, **params).execute(*multiparams, **params)
  File "C:\Python24\lib\site-packages\sqlalchemy\sql.py", line 354, in execute
    return e.execute_compiled(self, params)
  File "C:\Python24\lib\site-packages\sqlalchemy\engine.py", line 646, in execute_compiled
    self.pre_exec(proxy, compiled, parameters, **kwargs)
  File "C:\Python24\lib\site-packages\sqlalchemy\databases\mssql.py", line 300, in pre_exec
    if parameters.has_key(c.name):
AttributeError: 'list' object has no attribute 'has_key'

The code in MSSQLEngine.pre_exec() expects parameters to be a dict but in this case is is a list of dicts.

Comments (3)

  1. Log in to comment