Hi,

I am trying to use TurboGears and SQLAlchemy with an SQL Server back-end, using adodbapi as the connector. I've run into a couple of problems, which I have managed to solve. My initial thinking is that fixes could be included in SA/adodbapi, and if there is interest I can look at creating patches.

1) Running "tg-admin sql create" the tables don't actually create.
Turning on SQL echo, I can see suitable "create table" commands being issued. I tried doing this manually with adodbapi, found that I had to call connection.commit. Looking in SA, MSSQLDialect.do_commit does nothing if using adodbapi. I modified it to connection.commit() and the problem is solved. I can see there is some commented-out code in that part of mssql.py, related to this.

2) When accessing a model object from my TG app, I get an exception
...
File "build\bdist.win32\egg\sqlalchemy\engine\strategies.py", line 57, in connect
DBAPIError: (Connection failed) (InterfaceError)

Now, looking inside the code, the original exception turns out to be:
 com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
As an aside, the way adodbapi/sa try to generalise the errors actually makes tracking down the root cause harder.

In any case the solution is to call pythoncom.CoInitialize() I added this to the adodbapi connect() method, which fixed the problem for me. I'm not sure if this is the right place though. Also, a proper fix would also need to call CoUninitialize() at some point.

Ok, so I'm working for now. I am happy to help out getting these fixes incorporated in the libraries.

Best wishes,

Paul

--~--~---------~--~----~------------~-------~--~----~
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