djhenderson / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

AttributeError("type object 'PyCObject' has no attribute 'identity'",) #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i use Weave and when ill create a new user and it will return the lastrowid it 
will get an error:

Uncaught exception while processing request:
PUT /user/1.0/p3uthdcotxzwivqdpq5obz76rw7peufd
  File "/home/firefox/server-full/deps/server-core/services/util.py", line 303, in __call__
    return self.app(environ, start_response)
  File "/home/firefox/server-full/lib/python2.6/site-packages/paste/translogger.py", line 68, in __call__
    return self.application(environ, replacement_start_response)
  File "/home/firefox/server-full/lib/python2.6/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/home/firefox/server-full/lib/python2.6/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/firefox/server-full/deps/server-core/services/baseapp.py", line 220, in __notified
    response = func(self, request)
  File "/home/firefox/server-full/deps/server-core/services/baseapp.py", line 254, in __call__
    response = self._dispatch_request(request)
  File "/home/firefox/server-full/deps/server-core/services/baseapp.py", line 312, in _dispatch_request
    response = self._dispatch_request_with_match(request, match)
  File "/home/firefox/server-full/deps/server-core/services/baseapp.py", line 340, in _dispatch_request_with_match
    result = function(request, **params)
  File "/home/firefox/server-full/lib/python2.6/site-packages/metlog_py-0.9.5-py2.6.egg/metlog/decorators/base.py", line 151, in __call__
    return replacement(*args, **kwargs)
  File "/home/firefox/server-full/deps/server-core/services/metrics.py", line 101, in metlog_call
    return self._fn(*args, **kwargs)
  File "/usr/lib/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/firefox/server-full/deps/server-core/services/metrics.py", line 79, in thread_context
    yield _LOCAL_STORAGE.metlog_data
  File "/home/firefox/server-full/deps/server-core/services/metrics.py", line 101, in metlog_call
    return self._fn(*args, **kwargs)
  File "/home/firefox/server-full/lib/python2.6/site-packages/metlog_py-0.9.5-py2.6.egg/metlog/decorators/base.py", line 151, in __call__
    return replacement(*args, **kwargs)
  File "/home/firefox/server-full/lib/python2.6/site-packages/metlog_py-0.9.5-py2.6.egg/metlog/decorators/stats.py", line 49, in metlog_call
    result = self._fn(*args, **kwargs)
  File "/home/firefox/server-full/lib/python2.6/site-packages/metlog_py-0.9.5-py2.6.egg/metlog/decorators/base.py", line 151, in __call__
    return replacement(*args, **kwargs)
  File "/home/firefox/server-full/deps/server-core/services/metrics.py", line 114, in metlog_call
    result = self._fn(*args, **kwargs)
  File "/home/firefox/server-full/deps/server-reg/syncreg/controllers/user.py", line 267, in create_user
    email):
  File "/home/firefox/server-full/deps/server-core/services/user/sql.py", line 152, in create_user
    userobj['userid'] = res.lastrowid
  File "/home/firefox/server-full/lib/python2.6/site-packages/sqlalchemy/engine/base.py", line 2315, in lastrowid
    return self._saved_cursor.lastrowid
  File "/home/firefox/server-full/lib/python2.6/site-packages/sqlalchemy/pool.py", line 524, in __getattr__
    return getattr(self.cursor, key)
  File "pymssql.pyx", line 294, in pymssql.Cursor.lastrowid.__get__ (pymssql.c:3382)
<type 'exceptions.AttributeError'>
AttributeError("type object 'PyCObject' has no attribute 'identity'",)

is there any hope to fix it?

Greez Fank

Original issue reported on code.google.com by Florian....@fankserver.com on 4 Sep 2012 at 10:53

GoogleCodeExporter commented 9 years ago
Does the table have an IDENTITY column? I don't think that SQL Server will 
return a row id if the table has no IDENTITY column.

pymssql uses SCOPE_IDENTITY() to get the row id. So you could test this 
manually in SSMS by doing an INSERT into your table and then doing SELECT 
SCOPE_IDENTITY(). If this doesn't work, then pymssql won't be able to return a 
lastrowid either.

I'm closing this since it's very old, but if it's still a problem, post a 
comment and I'll reopen it.

Original comment by msabr...@gmail.com on 7 Aug 2013 at 6:13