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
This commit is contained in:
parent
0d2cf7bdd6
commit
d18f75af44
|
@ -1,12 +1,14 @@
|
||||||
from django.db.backends import BaseDatabaseClient
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from django.db.backends import BaseDatabaseClient
|
||||||
|
|
||||||
class DatabaseClient(BaseDatabaseClient):
|
class DatabaseClient(BaseDatabaseClient):
|
||||||
executable_name = 'mysql'
|
executable_name = 'mysql'
|
||||||
|
|
||||||
def runshell(self):
|
def runshell(self):
|
||||||
settings_dict = self.connection.settings_dict
|
settings_dict = self.connection.settings_dict
|
||||||
args = ['']
|
args = [self.executable_name]
|
||||||
db = settings_dict['DATABASE_OPTIONS'].get('db', settings_dict['DATABASE_NAME'])
|
db = settings_dict['DATABASE_OPTIONS'].get('db', settings_dict['DATABASE_NAME'])
|
||||||
user = settings_dict['DATABASE_OPTIONS'].get('user', settings_dict['DATABASE_USER'])
|
user = settings_dict['DATABASE_OPTIONS'].get('user', settings_dict['DATABASE_USER'])
|
||||||
passwd = settings_dict['DATABASE_OPTIONS'].get('passwd', settings_dict['DATABASE_PASSWORD'])
|
passwd = settings_dict['DATABASE_OPTIONS'].get('passwd', settings_dict['DATABASE_PASSWORD'])
|
||||||
|
@ -14,7 +16,7 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
port = settings_dict['DATABASE_OPTIONS'].get('port', settings_dict['DATABASE_PORT'])
|
port = settings_dict['DATABASE_OPTIONS'].get('port', settings_dict['DATABASE_PORT'])
|
||||||
defaults_file = settings_dict['DATABASE_OPTIONS'].get('read_default_file')
|
defaults_file = settings_dict['DATABASE_OPTIONS'].get('read_default_file')
|
||||||
# Seems to be no good way to set sql_mode with CLI.
|
# Seems to be no good way to set sql_mode with CLI.
|
||||||
|
|
||||||
if defaults_file:
|
if defaults_file:
|
||||||
args += ["--defaults-file=%s" % defaults_file]
|
args += ["--defaults-file=%s" % defaults_file]
|
||||||
if user:
|
if user:
|
||||||
|
@ -28,4 +30,8 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
if db:
|
if db:
|
||||||
args += [db]
|
args += [db]
|
||||||
|
|
||||||
os.execvp(self.executable_name, args)
|
if os.name == 'nt':
|
||||||
|
sys.exit(os.system(" ".join(args)))
|
||||||
|
else:
|
||||||
|
os.execvp(self.executable_name, args)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from django.db.backends import BaseDatabaseClient
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from django.db.backends import BaseDatabaseClient
|
||||||
|
|
||||||
class DatabaseClient(BaseDatabaseClient):
|
class DatabaseClient(BaseDatabaseClient):
|
||||||
executable_name = 'sqlplus'
|
executable_name = 'sqlplus'
|
||||||
|
@ -7,4 +9,8 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
def runshell(self):
|
def runshell(self):
|
||||||
conn_string = self.connection._connect_string()
|
conn_string = self.connection._connect_string()
|
||||||
args = [self.executable_name, "-L", conn_string]
|
args = [self.executable_name, "-L", conn_string]
|
||||||
os.execvp(self.executable_name, args)
|
if os.name == 'nt':
|
||||||
|
sys.exit(os.system(" ".join(args)))
|
||||||
|
else:
|
||||||
|
os.execvp(self.executable_name, args)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from django.db.backends import BaseDatabaseClient
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from django.db.backends import BaseDatabaseClient
|
||||||
|
|
||||||
class DatabaseClient(BaseDatabaseClient):
|
class DatabaseClient(BaseDatabaseClient):
|
||||||
executable_name = 'psql'
|
executable_name = 'psql'
|
||||||
|
@ -14,4 +16,8 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
if settings_dict['DATABASE_PORT']:
|
if settings_dict['DATABASE_PORT']:
|
||||||
args.extend(["-p", str(settings_dict['DATABASE_PORT'])])
|
args.extend(["-p", str(settings_dict['DATABASE_PORT'])])
|
||||||
args += [settings_dict['DATABASE_NAME']]
|
args += [settings_dict['DATABASE_NAME']]
|
||||||
os.execvp(self.executable_name, args)
|
if os.name == 'nt':
|
||||||
|
sys.exit(os.system(" ".join(args)))
|
||||||
|
else:
|
||||||
|
os.execvp(self.executable_name, args)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
from django.db.backends import BaseDatabaseClient
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from django.db.backends import BaseDatabaseClient
|
||||||
|
|
||||||
class DatabaseClient(BaseDatabaseClient):
|
class DatabaseClient(BaseDatabaseClient):
|
||||||
executable_name = 'sqlite3'
|
executable_name = 'sqlite3'
|
||||||
|
|
||||||
def runshell(self):
|
def runshell(self):
|
||||||
args = ['', self.connection.settings_dict['DATABASE_NAME']]
|
args = [self.executable_name,
|
||||||
os.execvp(self.executable_name, args)
|
self.connection.settings_dict['DATABASE_NAME']]
|
||||||
|
if os.name == 'nt':
|
||||||
|
sys.exit(os.system(" ".join(args)))
|
||||||
|
else:
|
||||||
|
os.execvp(self.executable_name, args)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue