from django.db.backends import BaseDatabaseClient
from django.conf import settings
import os
import sys

class DatabaseClient(BaseDatabaseClient):
    def runshell(self):
        if os.name=='nt':
            db = settings.DATABASE_OPTIONS.get('db', settings.DATABASE_NAME)
            user = settings.DATABASE_OPTIONS.get('user', settings.DATABASE_USER)
            passwdord = settings.DATABASE_OPTIONS.get('passwd', settings.DATABASE_PASSWORD)
            server = settings.DATABASE_OPTIONS.get('host', settings.DATABASE_HOST)
            port = settings.DATABASE_OPTIONS.get('port', settings.DATABASE_PORT)
            defaults_file = settings.DATABASE_OPTIONS.get('read_default_file')
    
            args = ['osql']
            if server:
                args += ["-S", server]
            if user:
                args += ["-U", user]
                if passwdord:
                    args += ["-P", passwdord]
            else:
                args += ["-E"] # Try trusted connection instead
            if db:
                args += ["-d", db]
            if defaults_file:
                args += ["-i", defaults_file]
    
            import subprocess
            try:
                retcode = subprocess.call(args, shell=True)
                if retcode:
                    print >>sys.stderr, "error level:", retcode
                    sys.exit(retcode)
            except KeyboardInterrupt:
                pass
            except OSError, e:
                print >> sys.stderr, "Execution failed:", e
        else:
            dsn = settings.DATABASE_OPTIONS.get('dsn', settings.DATABASE_ODBC_DSN)
            user = settings.DATABASE_OPTIONS.get('user', settings.DATABASE_USER)
            passwdord = settings.DATABASE_OPTIONS.get('passwd', settings.DATABASE_PASSWORD)
            args = ['isql -v %s %s %s' %(dsn,user,passwdord)]
    
            import subprocess
            try:
                retcode = subprocess.call(args, shell=True)
                if retcode:
                    print >>sys.stderr, "error level:", retcode
                    sys.exit(retcode)
            except KeyboardInterrupt:
                pass
            except OSError, e:
                print >> sys.stderr, "Execution failed:", e


@@ -357,33 +357,32 @@
            passw
-d
 ord = settings.D
@@ -431,32 +431,32 @@
 ABASE_PASSWORD)%0A
+
             serv
@@ -682,21 +682,17 @@
 _file')%0A
-    
 %0A
+
         
@@ -855,17 +855,16 @@
 if passw
-d
 ord:%0A   
@@ -900,17 +900,16 @@
 %22, passw
-d
 ord%5D%0A   
@@ -1117,21 +1117,17 @@
 s_file%5D%0A
-    
 %0A
+
         
@@ -1461,33 +1461,32 @@
         print %3E%3E
- 
 sys.stderr, %22Exe
@@ -1699,17 +1699,16 @@
    passw
-d
 ord = se
@@ -1822,29 +1822,26 @@
 dsn,
+ 
 user,
+ 
 passw
-d
 ord)%5D%0A
-    
 %0A   
@@ -2156,32 +2156,32 @@
 ept OSError, e:%0A
+
                 
@@ -2188,17 +2188,16 @@
 print %3E%3E
- 
 sys.stde

Fix typo, reformat.