|
0
|
1 |
import os |
|
|
2 |
import sys |
|
|
3 |
|
|
|
4 |
from django.db.backends import BaseDatabaseClient |
|
|
5 |
|
|
|
6 |
class DatabaseClient(BaseDatabaseClient): |
|
|
7 |
executable_name = 'psql' |
|
|
8 |
|
|
|
9 |
def runshell(self): |
|
|
10 |
settings_dict = self.connection.settings_dict |
|
|
11 |
args = [self.executable_name] |
|
29
|
12 |
if settings_dict['USER']: |
|
|
13 |
args += ["-U", settings_dict['USER']] |
|
|
14 |
if settings_dict['HOST']: |
|
|
15 |
args.extend(["-h", settings_dict['HOST']]) |
|
|
16 |
if settings_dict['PORT']: |
|
|
17 |
args.extend(["-p", str(settings_dict['PORT'])]) |
|
|
18 |
args += [settings_dict['NAME']] |
|
0
|
19 |
if os.name == 'nt': |
|
|
20 |
sys.exit(os.system(" ".join(args))) |
|
|
21 |
else: |
|
|
22 |
os.execvp(self.executable_name, args) |
|
|
23 |
|