2018-10-26 07:39:42 +08:00
|
|
|
import shutil
|
2009-04-11 19:41:35 +08:00
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
from django.db.backends.base.client import BaseDatabaseClient
|
2006-05-26 13:37:21 +08:00
|
|
|
|
2013-07-08 08:39:54 +08:00
|
|
|
|
2008-08-11 20:11:25 +08:00
|
|
|
class DatabaseClient(BaseDatabaseClient):
|
2008-09-09 10:13:58 +08:00
|
|
|
executable_name = 'sqlplus'
|
2018-10-26 07:39:42 +08:00
|
|
|
wrapper_name = 'rlwrap'
|
2008-09-09 10:13:58 +08:00
|
|
|
|
2020-10-05 06:25:29 +08:00
|
|
|
@staticmethod
|
|
|
|
def connect_string(settings_dict):
|
|
|
|
from django.db.backends.oracle.utils import dsn
|
|
|
|
|
|
|
|
return '%s/"%s"@%s' % (
|
|
|
|
settings_dict['USER'],
|
|
|
|
settings_dict['PASSWORD'],
|
|
|
|
dsn(settings_dict),
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def settings_to_cmd_args_env(cls, settings_dict, parameters):
|
|
|
|
args = [cls.executable_name, '-L', cls.connect_string(settings_dict)]
|
|
|
|
wrapper_path = shutil.which(cls.wrapper_name)
|
2018-10-26 07:39:42 +08:00
|
|
|
if wrapper_path:
|
|
|
|
args = [wrapper_path, *args]
|
2020-04-14 15:56:40 +08:00
|
|
|
args.extend(parameters)
|
2020-10-05 06:25:29 +08:00
|
|
|
return args, None
|