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

用法
其用法可以直接查詢命令行幫助文檔:
# 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
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
django將圖片保存到mysql數據庫并展示在前端頁面的實現
這篇文章主要介紹了django將圖片保存到mysql數據庫并展示在前端頁面的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-05-05

