摘要:
安装 pip install alembic 初始化 alembic init alembic 修改配置alembic.ini sqlalchemy.url = driver://user:pass@localhost/dbname 修改env.py import sys from logging. 阅读全文
摘要:
class MixToJson: def single_to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns} def dobule_to_dict(self): result = { 阅读全文
摘要:
生成全部模型 import os cmd = "sqlacodegen mysql+pymysql://root:123456@192.168.1.14/management >tmp.py" os.system(cmd) 生成指定模型 import os cmd = "sqlacodegen -- 阅读全文
摘要:
一、装饰器是什么 python的装饰器本质上是一个Python函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,装饰器的返回值也是一个函数对象。简单的说装饰器就是一个用来返回函数的函数。 它经常用于有切面需求的场景,比如:插入日志、性能测试、事务处理、缓存、权限校验等场景。装饰器是解 阅读全文
摘要:
import time def count_time(func): def wrapper(*args, **kwargs): start_time = time.time() count = func(*args, **kwargs) print('程序共计%s秒' % (time.time() 阅读全文
摘要:
Nginx配置文件(/usr/local/nginx/conf/nginx.conf)主要由四部分组成:main(全区设置),server(主机配置),upstream(负载均衡服务器设置),和location(URL匹配特定位置设置) #定义nginx运行的用户和用户组 user www www; 阅读全文
摘要:
解决方法: use mysql;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '复杂一点的密码'; flush privileges; 阅读全文
摘要:
SSH 最常用的登陆方法是ssh username@server -p port 本文将通过~/.ssh/confg配置文件,实现免密、更改名称的登陆方法,不论你的username、server address、port是什么,都可以不用输入,只需要输入一个替换的名称即可登陆该服务器。像这样ssh 阅读全文
摘要:
在开发过程中,当需要使用python的包时可以联网安装 sudo pip3 install 包名称 使用如上命令,会将包安装到/usr/local/lib/python3.5/dist-packages下。 产生的问题 如果在一台机器上,想开发多个不同的项目,需要用到同一个包的不同版本,如果还使用上 阅读全文
摘要:
pip install -i https://pypi.doubanio.com/simple/ -r requirements.txt 单独使用豆瓣源安装第三方模块:pip install django -i https://pypi.doubanio.com/simple/ 一劳永逸的做法:换源 阅读全文