sqlacodegen使用

import os
from pathlib import Path


def run():
    models_path = Path(__file__).parent / 'model.py'
    args = f'sqlacodegen --noviews --outfile {models_path} mysql+pymysql://root:123456@localhost:3306/web'
    print(args)
    os.system(args)
    print('done')


if __name__ == '__main__':
    run()

如果报错ImportError: cannot import name 'ArgSpec' from 'inspect'
修改代码Lib\site-packages\sqlacodegen\codegen.py, line 9

if not hasattr(inspect, 'getfullargspec'):
    from inspect import ArgSpec
# from inspect import ArgSpec  #注释这行,加上上面两行

posted on 2024-01-18 15:39  ishuangjin  阅读(371)  评论(0)    收藏  举报

导航