django 快速启动数据库客户端程序的方法示例

发布时间:2020-10-19 20:05:27 作者:Martin91
来源:脚本之家 阅读:130

实际工作经历中,免不了有时候需要连接数据库进行问题排查分析的场景,之前一直习惯通过 mysql -uxxx -hxxxx -P1234 ... 这样的方式来启动命令行形式的 MySQL 数据库客户端程序,只是用起来比较麻烦,每次都要拷贝各个配置参数,还要记得不要在命令里显式打印密码。后来想起来在开发 Ruby on Rails 程序的时候,其提供了 rails dbconsole 的命令,可以方便直接启动对应的数据库客户端命令行程序,联想到 Django 理论上也有,所以找到了 python manage.py dbshell 这个命令,使用效果和自己手动敲 mysql 命令行是一样的,省去繁琐的参数设定步骤。

使用效果

django 快速启动数据库客户端程序的方法示例

用法

其用法可以直接查询命令行帮助文档:

# 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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持亿速云。

推荐阅读:
  1. 探索Django ORM的极限
  2. Django 模型类—查询

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

django 数据库 客户端程序

上一篇:C# WebApi 异常处理解决方案

下一篇:Javascript中的getter和setter初识

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》