Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10357 -- Fixed the "dbshell" command for Windows users.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10517 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d18f75af447bc18b062564ab163943c16d79effc 1 parent 0d2cf7b
Malcolm Tredinnick authored
14  django/db/backends/mysql/client.py
... ...
@@ -1,12 +1,14 @@
1  
-from django.db.backends import BaseDatabaseClient
2 1
 import os
  2
+import sys
  3
+
  4
+from django.db.backends import BaseDatabaseClient
3 5
 
4 6
 class DatabaseClient(BaseDatabaseClient):
5 7
     executable_name = 'mysql'
6 8
 
7 9
     def runshell(self):
8 10
         settings_dict = self.connection.settings_dict
9  
-        args = ['']
  11
+        args = [self.executable_name]
10 12
         db = settings_dict['DATABASE_OPTIONS'].get('db', settings_dict['DATABASE_NAME'])
11 13
         user = settings_dict['DATABASE_OPTIONS'].get('user', settings_dict['DATABASE_USER'])
12 14
         passwd = settings_dict['DATABASE_OPTIONS'].get('passwd', settings_dict['DATABASE_PASSWORD'])
@@ -14,7 +16,7 @@ def runshell(self):
14 16
         port = settings_dict['DATABASE_OPTIONS'].get('port', settings_dict['DATABASE_PORT'])
15 17
         defaults_file = settings_dict['DATABASE_OPTIONS'].get('read_default_file')
16 18
         # Seems to be no good way to set sql_mode with CLI.
17  
-    
  19
+
18 20
         if defaults_file:
19 21
             args += ["--defaults-file=%s" % defaults_file]
20 22
         if user:
@@ -28,4 +30,8 @@ def runshell(self):
28 30
         if db:
29 31
             args += [db]
30 32
 
31  
-        os.execvp(self.executable_name, args)
  33
+        if os.name == 'nt':
  34
+            sys.exit(os.system(" ".join(args)))
  35
+        else:
  36
+            os.execvp(self.executable_name, args)
  37
+
10  django/db/backends/oracle/client.py
... ...
@@ -1,5 +1,7 @@
1  
-from django.db.backends import BaseDatabaseClient
2 1
 import os
  2
+import sys
  3
+
  4
+from django.db.backends import BaseDatabaseClient
3 5
 
4 6
 class DatabaseClient(BaseDatabaseClient):
5 7
     executable_name = 'sqlplus'
@@ -7,4 +9,8 @@ class DatabaseClient(BaseDatabaseClient):
7 9
     def runshell(self):
8 10
         conn_string = self.connection._connect_string()
9 11
         args = [self.executable_name, "-L", conn_string]
10  
-        os.execvp(self.executable_name, args)
  12
+        if os.name == 'nt':
  13
+            sys.exit(os.system(" ".join(args)))
  14
+        else:
  15
+            os.execvp(self.executable_name, args)
  16
+
10  django/db/backends/postgresql/client.py
... ...
@@ -1,5 +1,7 @@
1  
-from django.db.backends import BaseDatabaseClient
2 1
 import os
  2
+import sys
  3
+
  4
+from django.db.backends import BaseDatabaseClient
3 5
 
4 6
 class DatabaseClient(BaseDatabaseClient):
5 7
     executable_name = 'psql'
@@ -14,4 +16,8 @@ def runshell(self):
14 16
         if settings_dict['DATABASE_PORT']:
15 17
             args.extend(["-p", str(settings_dict['DATABASE_PORT'])])
16 18
         args += [settings_dict['DATABASE_NAME']]
17  
-        os.execvp(self.executable_name, args)
  19
+        if os.name == 'nt':
  20
+            sys.exit(os.system(" ".join(args)))
  21
+        else:
  22
+            os.execvp(self.executable_name, args)
  23
+
13  django/db/backends/sqlite3/client.py
... ...
@@ -1,9 +1,16 @@
1  
-from django.db.backends import BaseDatabaseClient
2 1
 import os
  2
+import sys
  3
+
  4
+from django.db.backends import BaseDatabaseClient
3 5
 
4 6
 class DatabaseClient(BaseDatabaseClient):
5 7
     executable_name = 'sqlite3'
6 8
 
7 9
     def runshell(self):
8  
-        args = ['', self.connection.settings_dict['DATABASE_NAME']]
9  
-        os.execvp(self.executable_name, args)
  10
+        args = [self.executable_name,
  11
+                self.connection.settings_dict['DATABASE_NAME']]
  12
+        if os.name == 'nt':
  13
+            sys.exit(os.system(" ".join(args)))
  14
+        else:
  15
+            os.execvp(self.executable_name, args)
  16
+

0 notes on commit d18f75a

Please sign in to comment.
Something went wrong with that request. Please try again.