django 快速启动数据库客户端程序的方法示例
作者:Martin91 时间:2023-07-31 09:31:59
实际工作经历中,免不了有时候需要连接数据库进行问题排查分析的场景,之前一直习惯通过 mysql -uxxx -hxxxx -P1234 ...
这样的方式来启动命令行形式的 MySQL 数据库客户端程序,只是用起来比较麻烦,每次都要拷贝各个配置参数,还要记得不要在命令里显式打印密码。后来想起来在开发 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
来源:https://segmentfault.com/a/1190000020084013
标签:django,数据库,客户端程序
0
投稿
猜你喜欢
MySQL 8.0.18使用clone plugin重建MGR的实现
2024-01-24 11:21:30
postman传递当前时间戳实例详解
2022-01-09 17:28:34
Yolov5多边形标签和JSON数据格式转换
2023-11-06 17:31:24
深入理解Python虚拟机中复数(complex)的实现原理及源码剖析
2023-10-24 23:02:50
PythonPC客户端自动化实现原理(pywinauto)
2022-11-27 02:24:27
Sql Server中常用的6个自定义函数分享
2024-01-17 05:05:40
python实现网络五子棋
2021-10-16 23:58:17
python 利用jieba.analyse进行 关键词提取
2021-03-16 22:11:26
python扫描proxy并获取可用代理ip的实例
2023-07-29 16:42:50
如何用用Python制作NFT区块链作品
2022-11-21 22:51:09
asp php 清空access mysql mssql数据库的代码
2023-11-20 21:49:13
python实现从一组颜色中找出与给定颜色最接近颜色的方法
2023-04-23 01:48:44
Go语言基础for循环语句的用法及示例详解
2024-02-07 16:15:34
MySQL身份认证漏洞 升级到5.5.24可修正
2012-07-11 15:54:09
Mysql中FIND_IN_SET()和IN区别简析
2024-01-23 12:12:04
基于Python实现本地音乐播放器的制作
2022-05-11 16:37:46
使用微信助手搭建微信返利机器人流程
2022-10-10 08:34:03
pandas 层次化索引的实现方法
2023-11-24 19:04:02
python自动化生成IOS的图标
2021-04-26 19:16:34
Python使用MySQLdb for Python操作数据库教程
2024-01-23 06:49:04