2008-08-11 20:11:25 +08:00
|
|
|
from django.db.backends import BaseDatabaseClient
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.conf import settings
|
|
|
|
import os
|
|
|
|
|
2008-08-11 20:11:25 +08:00
|
|
|
class DatabaseClient(BaseDatabaseClient):
|
2008-09-09 10:13:58 +08:00
|
|
|
executable_name = 'psql'
|
|
|
|
|
2008-08-11 20:11:25 +08:00
|
|
|
def runshell(self):
|
2008-09-09 10:13:58 +08:00
|
|
|
args = [self.executable_name]
|
2008-08-11 20:11:25 +08:00
|
|
|
if settings.DATABASE_USER:
|
|
|
|
args += ["-U", settings.DATABASE_USER]
|
|
|
|
if settings.DATABASE_PASSWORD:
|
|
|
|
args += ["-W"]
|
|
|
|
if settings.DATABASE_HOST:
|
|
|
|
args.extend(["-h", settings.DATABASE_HOST])
|
|
|
|
if settings.DATABASE_PORT:
|
|
|
|
args.extend(["-p", str(settings.DATABASE_PORT)])
|
|
|
|
args += [settings.DATABASE_NAME]
|
2008-09-09 10:13:58 +08:00
|
|
|
os.execvp(self.executable_name, args)
|