Ticket #1631: dbclient.patch

File dbclient.patch, 4.3 KB (added by pb, 18 years ago)

patch

  • django/db/backends/postgresql/base.py

     
    9898def get_random_function_sql():
    9999    return "RANDOM()"
    100100
     101def 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
    101116# Register these custom typecasts, because Django expects dates/times to be
    102117# in Python's native (standard-library) datetime/time format, whereas psycopg
    103118# use mx.DateTime by default.
  • django/db/backends/sqlite3/base.py

     
    128128    elif lookup_type == 'day':
    129129        return "%i-%02i-%02i 00:00:00" % (dt.year, dt.month, dt.day)
    130130
     131def 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                               
    131138# SQLite requires LIKE statements to include an ESCAPE clause if the value
    132139# being escaped has a percent or underscore in it.
    133140# See http://www.sqlite.org/lang_expr.html for an explanation.
  • django/db/backends/mysql/base.py

     
    146146def get_random_function_sql():
    147147    return "RAND()"
    148148
     149def 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
    149164OPERATOR_MAPPING = {
    150165    'exact': '= %s',
    151166    'iexact': 'LIKE %s',
  • django/db/backends/dummy/base.py

     
    2323    def close(self):
    2424        pass # close()
    2525
     26def exec_client():
     27    print "DATABASE_ENGINE is not set."
     28
    2629supports_constraints = False
    2730quote_name = complain
    2831dictfetchone = complain
  • django/core/management.py

     
    10381038        code.interact()
    10391039run_shell.args = '[--plain]'
    10401040
     1041def dbclient():
     1042    """Run interactive client for current DATABASE_ENGINE"""
     1043    from django.db import backend
     1044    backend.exec_client()
     1045dbclient.args = ""
     1046
    10411047# Utilities for command-line script
    10421048
    10431049DEFAULT_ACTION_MAPPING = {
    10441050    'adminindex': get_admin_index,
    10451051    'createcachetable' : createcachetable,
     1052    'dbclient': dbclient,
    10461053    'diffsettings': diffsettings,
    10471054    'inspectdb': inspectdb,
    10481055    'install': install,
     
    10651072NO_SQL_TRANSACTION = (
    10661073    'adminindex',
    10671074    'createcachetable',
     1075    'dbclient',
    10681076    'diffsettings',
    10691077    'install',
    10701078    'reset',
    10711079    'sqlindexes',
    1072     'syncdb'
     1080    'syncdb',
    10731081)
    10741082
    10751083class DjangoOptionParser(OptionParser):
     
    11311139
    11321140    if action == 'shell':
    11331141        action_mapping[action](options.plain is True)
    1134     elif action in ('syncdb', 'validate', 'diffsettings'):
     1142    elif action in ('syncdb', 'validate', 'diffsettings', 'dbclient'):
    11351143        action_mapping[action]()
    11361144    elif action == 'inspectdb':
    11371145        try:
Back to Top