Hi,

I write a patch for using with statement in python 2.5 and up for multi 
database access, example code like this:

# test.py
from __future__ import with_statement
from django.contrib.auth.models import User
from django.db import using

with using('db1'):
    print User.objects.count() # db1 user count
    with using('db2'):
        print User.objects.count() # db2 user count
print User.objects.count() # default db user count

#settings.py

# default db
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'test.db' 

# others
DATABASES = {
 'db1': dict(
            DATABASE_ENGINE = 'sql_server.pyodbc',
            DATABASE_NAME = 'db1',
            DATABASE_USER = 'user',
            DATABASE_PASSWORD = 'password',
            DATABASE_ODBC_DSN = 'DSN1',
            DATABASE_COLLATION = 'Chinese_PRC_CI_AS',
 ),
 'db2': dict(
            DATABASE_ENGINE = 'sqlite3',
            DATABASE_NAME = 'db2.db',
 ),
}

Please see patch in the attchments, comment welcome.

Regards,
Wei guangjing

--
http://code.google.com/p/django-pyodbc



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: multidb.diff
Description: Binary data

Reply via email to