[IronPython] Making adonet-dbapi's dbapi a drop-in replacement in django-mssql

Markus Törnqvist mjt at nysv.org
Tue Oct 27 13:05:15 CET 2009


Hi!

Got adonet-dbapi from http://bitbucket.org/jdhardy/adonet-dbapi/ and
trying to integrate it to django-mssql.

What needs to be done is:
  1. Move sqlserver_ado\dbapi.py out of the way
  2. Copy X:\adonet-dbapi\dbapi\dbapi\ in its stead
  3. Copy mssql.py into the new sqlserver_ado\dbapi\ directory
  4. Edit the sqlserver_ado\dbapi\__init__.py file so it looks like this:

from common import *
from generic import *

import mssql

def connect(connect_string, timeout=None):
  return odbc.connect(connect_string)

  5. Edit the mssql.py file's imports to these:
from common import *
from generic import generic_connect, Connection as GenericConnection, Cursor as GenericCursor

  Now it complains the PROVIDER keyword is not supported!

  6. Edit the mssql.py file and rewrite the connect function to this:
def connect(connstr):
    relevant_parts = [part for part in connstr.split(';') if not part.upper().startswith('PROVIDER')]
    connstr = ';'.join(relevant_parts)
    return generic_connect("System.Data", "System.Data.SqlClient.SqlConnection", connstr)

What do you guys, mainly Jeff and Vernon I guess ;), think about this?

There's also an error now which I'm working on:

Creating cursor 501
Creating cursor 5
adonet2dbapi: executing 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' UNION SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS' with '()'
Creating cursor 303
adonet2dbapi: executing 'SELECT [django_content_type].[id], [django_content_type].[name], [django_content_type].[app_label], [django_content_type].[model] FROM [django_content_type] WHERE ([django_content_type].[model] = %s  AND [django_content_type].[app_label] = %s ) ORDER BY [django_content_type].[name] ASC' with '('permission', 'auth')'

EnvironmentError: System.Data.SqlClient.SqlException: Incorrect syntax near 's'.

Hints are always welcome ;)

Thanks!

-- 
mjt




More information about the Ironpython-users mailing list