I've run into an error trying to use sqlalchemy with adodbapi to
connect to Microsoft SQL Server. The error occurs when the model is
initialized. Here is the simple model code, that attempts to retrieve
the schema info from the database:
from sqlalchemy import *
from turbogears.database import metadata, session, bind_meta_data
from sqlalchemy.ext.assignmapper import assign_mapper
class Question( ):
pass
bind_meta_data()
questions = Table( 'question', metadata, autoload=True )
assign_mapper( session.context, questions, Question )
The exception that is thrown is the following:
File "F:\Python25\lib\site-packages\sqlalchemy-0.3.8-py2.5.egg
\sqlalchemy\engine\base.py", line 602, in _execute
sqlalchemy.exceptions.SQLError: (DatabaseError)
-----------
Strategy 1: Traceback:Traceback (most recent call last):
File "F:\Python25\lib\site-packages\adodbapi-1.0.1-py2.5.egg
\adodbapi\adodbapi.py", line 540, in executeHelper
adoRetVal=self.cmd.Execute()
File "<COMObject ADODB.Command>", line 3, in Execute
File "f:\python25\lib\site-packages\win32com\client\dynamic.py",
line 258, in
_ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB
Provider for SQL Server', 'Cannot create new connection because in
manual or distributed transaction mode.', None, 0, -2147467259), None)
...
This SQL Server error is documented in their knowledge base (http://
support.microsoft.com/kb/272358). The problem appears to be related
to the way turbogears or sqlalchemy opens connections to the database
and when transactions are committed.
I've seen suggestions that recommend pyODBC over adodbapi, so I'll
give that a shot next. In the meantime, I wanted to report this
issue, as I didn't see it reported elsewhere. Since the problem
appears to be related to the database logic, I'm not hopeful pyODBC
will resolve the issue.
Regards,
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---