溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

django 快速啟動數(shù)據(jù)庫客戶端程序的方法示例

發(fā)布時(shí)間:2020-10-19 20:05:27 來源:腳本之家 閱讀:144 作者:Martin91 欄目:開發(fā)技術(shù)

實(shí)際工作經(jīng)歷中,免不了有時(shí)候需要連接數(shù)據(jù)庫進(jìn)行問題排查分析的場景,之前一直習(xí)慣通過 mysql -uxxx -hxxxx -P1234 ... 這樣的方式來啟動命令行形式的 MySQL 數(shù)據(jù)庫客戶端程序,只是用起來比較麻煩,每次都要拷貝各個(gè)配置參數(shù),還要記得不要在命令里顯式打印密碼。后來想起來在開發(fā) Ruby on Rails 程序的時(shí)候,其提供了 rails dbconsole 的命令,可以方便直接啟動對應(yīng)的數(shù)據(jù)庫客戶端命令行程序,聯(lián)想到 Django 理論上也有,所以找到了 python manage.py dbshell 這個(gè)命令,使用效果和自己手動敲 mysql 命令行是一樣的,省去繁瑣的參數(shù)設(shè)定步驟。

使用效果

django 快速啟動數(shù)據(jù)庫客戶端程序的方法示例

用法

其用法可以直接查詢命令行幫助文檔:

# python manage.py dbshell -h
Usage: manage.py dbshell [options]

Runs the command-line client for specified database, or the default database if none is provided.

Options:
 -v VERBOSITY, --verbosity=VERBOSITY
      Verbosity level; 0=minimal output, 1=normal output,
      2=verbose output, 3=very verbose output
 --settings=SETTINGS The Python path to a settings module, e.g.
      "myproject.settings.main". If this isn't provided, the
      DJANGO_SETTINGS_MODULE environment variable will be
      used.
 --pythonpath=PYTHONPATH
      A directory to add to the Python path, e.g.
      "/home/djangoprojects/myproject".
 --traceback   Raise on exception
 --database=DATABASE Nominates a database onto which to open a shell.
      Defaults to the "default" database.
 --version    show program's version number and exit
 -h, --help   show this help message and exit

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI