Voici la procédure pour le faire sur un Amazon Linux 2 propre.
OS: AmazonLinux2 (Linux version 4.14.193-149.317.amzn2.x86_64) python: Python 2.7.18
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install sqlacodegen pymysql
sqlacodegen mysql+pymysql://user:password@sqlhost/dbname
option: --outfile --tables Cela imprimera les définitions SQL Alchemy pour toutes les tables dans la sortie standard
Le site officiel dit d'utiliser ʻoursql, mais dans cet environnement, l'erreur suivante se produira, alors utilisez
pymysql`.
https://pypi.org/project/sqlacodegen/
Traceback (most recent call last):
File "/home/ec2-user/.local/bin/sqlacodegen", line 8, in <module>
sys.exit(main())
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlacodegen/main.py", line 44, in main
engine = create_engine(args.url)
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 61, in create
entrypoint = u._get_entrypoint()
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/engine/url.py", line 172, in _get_entrypoint
cls = registry.load(name)
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 254, in load
loader = self.auto_fn(name)
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/dialects/__init__.py", line 32, in _auto_fn
dialect, driver = name.split(".")
ValueError: too many values to unpack
Recommended Posts