Ticket #1631: dbclient.patch
File dbclient.patch, 4.3 KB (added by , 19 years ago) |
---|
-
django/db/backends/postgresql/base.py
98 98 def get_random_function_sql(): 99 99 return "RANDOM()" 100 100 101 def exec_client(): 102 """Execute psql commandline client using current project's DB settings""" 103 from django.conf import settings 104 import os 105 args = [''] 106 args += ["-U %s" % settings.DATABASE_USER] 107 if settings.DATABASE_PASSWORD: 108 args += ["-W"] 109 if settings.DATABASE_HOST: 110 args += ["-h %s" % settings.DATABASE_HOST] 111 if settings.DATABASE_PORT: 112 args += ["-p %s" % settings.DATABASE_PORT] 113 args += [settings.DATABASE_NAME] 114 os.execvp('psql', args) 115 101 116 # Register these custom typecasts, because Django expects dates/times to be 102 117 # in Python's native (standard-library) datetime/time format, whereas psycopg 103 118 # use mx.DateTime by default. -
django/db/backends/sqlite3/base.py
128 128 elif lookup_type == 'day': 129 129 return "%i-%02i-%02i 00:00:00" % (dt.year, dt.month, dt.day) 130 130 131 def exec_client(): 132 """Execute SQLite client using current DB settings""" 133 from django.conf import settings 134 import os 135 args = ['', settings.DATABASE_NAME] 136 os.execvp('sqlite3', args) 137 131 138 # SQLite requires LIKE statements to include an ESCAPE clause if the value 132 139 # being escaped has a percent or underscore in it. 133 140 # See http://www.sqlite.org/lang_expr.html for an explanation. -
django/db/backends/mysql/base.py
146 146 def get_random_function_sql(): 147 147 return "RAND()" 148 148 149 def exec_client(): 150 """Execute MySQL commandline client using current project's DB settings""" 151 from django.conf import settings 152 import os 153 args = [''] 154 args += ["--user=%s" % settings.DATABASE_USER] 155 if settings.DATABASE_PASSWORD: 156 args += ["--password=%s" % settings.DATABASE_PASSWORD] 157 if settings.DATABASE_HOST: 158 args += ["--host=%s" % settings.DATABASE_HOST] 159 if settings.DATABASE_PORT: 160 args += ["--port=%s" % settings.DATABASE_PORT] 161 args += [settings.DATABASE_NAME] 162 os.execvp('mysql', args) 163 149 164 OPERATOR_MAPPING = { 150 165 'exact': '= %s', 151 166 'iexact': 'LIKE %s', -
django/db/backends/dummy/base.py
23 23 def close(self): 24 24 pass # close() 25 25 26 def exec_client(): 27 print "DATABASE_ENGINE is not set." 28 26 29 supports_constraints = False 27 30 quote_name = complain 28 31 dictfetchone = complain -
django/core/management.py
1038 1038 code.interact() 1039 1039 run_shell.args = '[--plain]' 1040 1040 1041 def dbclient(): 1042 """Run interactive client for current DATABASE_ENGINE""" 1043 from django.db import backend 1044 backend.exec_client() 1045 dbclient.args = "" 1046 1041 1047 # Utilities for command-line script 1042 1048 1043 1049 DEFAULT_ACTION_MAPPING = { 1044 1050 'adminindex': get_admin_index, 1045 1051 'createcachetable' : createcachetable, 1052 'dbclient': dbclient, 1046 1053 'diffsettings': diffsettings, 1047 1054 'inspectdb': inspectdb, 1048 1055 'install': install, … … 1065 1072 NO_SQL_TRANSACTION = ( 1066 1073 'adminindex', 1067 1074 'createcachetable', 1075 'dbclient', 1068 1076 'diffsettings', 1069 1077 'install', 1070 1078 'reset', 1071 1079 'sqlindexes', 1072 'syncdb' 1080 'syncdb', 1073 1081 ) 1074 1082 1075 1083 class DjangoOptionParser(OptionParser): … … 1131 1139 1132 1140 if action == 'shell': 1133 1141 action_mapping[action](options.plain is True) 1134 elif action in ('syncdb', 'validate', 'diffsettings' ):1142 elif action in ('syncdb', 'validate', 'diffsettings', 'dbclient'): 1135 1143 action_mapping[action]() 1136 1144 elif action == 'inspectdb': 1137 1145 try: