Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #9972: The dbshell command was ignoring the DATABASE_HOST and D…

…ATABASE_PORT settings in Oracle.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9713 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c20019a91d7d553606f45d21c513f277fb98deb4 1 parent 300752b
@ikelly ikelly authored
View
28 django/db/backends/oracle/base.py
@@ -245,23 +245,23 @@ def __init__(self, *args, **kwargs):
def _valid_connection(self):
return self.connection is not None
+ def _connect_string(self, settings):
+ if len(settings.DATABASE_HOST.strip()) == 0:
+ settings.DATABASE_HOST = 'localhost'
+ if len(settings.DATABASE_PORT.strip()) != 0:
+ dsn = '%s:%s/%s' % (settings.DATABASE_HOST,
+ settings.DATABASE_PORT,
+ settings.DATABASE_NAME)
+ else:
+ dsn = settings.DATABASE_NAME
+ return "%s/%s@%s" % (settings.DATABASE_USER,
+ settings.DATABASE_PASSWORD, dsn)
+
def _cursor(self, settings):
cursor = None
if not self._valid_connection():
- if len(settings.DATABASE_HOST.strip()) == 0:
- settings.DATABASE_HOST = 'localhost'
- if len(settings.DATABASE_PORT.strip()) != 0:
- dsn = Database.makedsn(settings.DATABASE_HOST,
- int(settings.DATABASE_PORT),
- settings.DATABASE_NAME)
- self.connection = Database.connect(settings.DATABASE_USER,
- settings.DATABASE_PASSWORD,
- dsn, **self.options)
- else:
- conn_string = "%s/%s@%s" % (settings.DATABASE_USER,
- settings.DATABASE_PASSWORD,
- settings.DATABASE_NAME)
- self.connection = Database.connect(conn_string, **self.options)
+ conn_string = self._connect_string(settings)
+ self.connection = Database.connect(conn_string, **self.options)
cursor = FormatStylePlaceholderCursor(self.connection)
# Set oracle date to ansi date format. This only needs to execute
# once when we create a new connection.
View
9 django/db/backends/oracle/client.py
@@ -6,10 +6,7 @@ class DatabaseClient(BaseDatabaseClient):
executable_name = 'sqlplus'
def runshell(self):
- dsn = settings.DATABASE_USER
- if settings.DATABASE_PASSWORD:
- dsn += "/%s" % settings.DATABASE_PASSWORD
- if settings.DATABASE_NAME:
- dsn += "@%s" % settings.DATABASE_NAME
- args = [self.executable_name, "-L", dsn]
+ from django.db import connection
+ conn_string = connection._connect_string(settings)
+ args = [self.executable_name, "-L", conn_string]
os.execvp(self.executable_name, args)
Please sign in to comment.
Something went wrong with that request. Please try again.