07 2020 档案

摘要:使用 contextmanager 来管理 from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session,sessionmaker db_connect = "mysql+pymysql://root:p 阅读全文
posted @ 2020-07-19 16:43 John-Python 阅读(602) 评论(0) 推荐(0) 编辑
摘要:关于Join 如上图所示,left join和inner join的取值范围还是有很明显的不同的,看网上不少文章优化left join也不交代上下文环境,直接就是教唆把left join换成inner join,只能说是章口就莱,文体两开花... 关于笛卡尔积 简言之就是强拼,不带条件的硬拼2(多) 阅读全文
posted @ 2020-07-19 15:34 John-Python 阅读(827) 评论(0) 推荐(0) 编辑
摘要:安装 pip install alembic 初始化 alembic init alembic 修改配置alembic.ini sqlalchemy.url = driver://user:pass@localhost/dbname 修改env.py import sys from logging. 阅读全文
posted @ 2020-07-19 00:15 John-Python 阅读(810) 评论(0) 推荐(0) 编辑
摘要: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 = { 阅读全文
posted @ 2020-07-13 17:53 John-Python 阅读(1652) 评论(0) 推荐(0) 编辑
摘要:生成全部模型 import os cmd = "sqlacodegen mysql+pymysql://root:123456@192.168.1.14/management >tmp.py" os.system(cmd) 生成指定模型 import os cmd = "sqlacodegen -- 阅读全文
posted @ 2020-07-10 14:16 John-Python 阅读(770) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示