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 #注释这行,加上上面两行
标签:__,args,sqlacodegen,inspect,ArgSpec,使用,import
From: https://www.cnblogs.com/ishuangjin/p/17972623