flask_migrate鏁版嵁搴撹縼绉婚亣鍒扮殑闂

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flask_migrate鏁版嵁搴撹縼绉婚亣鍒扮殑闂相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/UNC' title='UNC'>UNC   odi   str   eve   cli   dev   name   man   cti   

鏈汉浣跨敤鐨刾ython鍜宲ip鐗堟湰閮芥槸3.6锛屼互涓嬩緥瀛愬熀浜庢鐗堟湰銆?/p>

鏈汉缂栧啓鐨刴anager.py鏂囦欢

# coding:utf-8

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from ihome import create_app, db


app = create_app(鈥?/span>development鈥?/span>)

manager = Manager(app)
# 闆嗘垚鏁版嵁搴撶殑杩佺Щ
Migrate(app, db)
manager.add_command(鈥?/span>db鈥?/span>, MigrateCommand)


if __name__ == 鈥?/span>__main__鈥?/span>:
    manager.run()

鏁版嵁搴撹縼绉绘楠ゅ涓嬶細

1. python3.6 manager.py db init

2. python3.6 manager.py db migrate

姝ラ2閬囧埌濡備笅闂锛?/p>

ModuleNotFoundError: No module named 鈥楳ySQLdb鈥?/p>

瑙e喅鏂规硶锛?/p>

pip3 install mysqlclient

瀹夎mysqlclient杩囩▼涓亣鍒板涓嬮棶棰橈細

闂1锛?/p>

OSError: mysql_config not found

瑙e喅鏂规硶锛?/p>

yum install mysql-devel

闂2锛?/p>

fatal error: Python.h: No such file or directory

瑙e喅鏂规硶锛?/span>

yum install python36-devel

3. python3.6 manager.py db upgrade

鑷虫锛屾暟鎹簱杩佺Щ瀹屾垚銆?/p>

以上是关于flask_migrate鏁版嵁搴撹縼绉婚亣鍒扮殑闂的主要内容,如果未能解决你的问题,请参考以下文章

闈㈣瘯瀹橈細鏁版嵁搴撹繛鎺ユ睜涓轰粈涔堥兘瑕佺敤Threadlocal鍛紵

鍩轰簬SpringBoot鎼缓涓€涓甫鏁版嵁搴撹闂殑WEB椤圭洰(璁板綍鎵€闇€鐨勪緷璧?閰嶇疆,椹卞姩瀹夎绛夋敞鎰忎簨椤?

JavaWeb涓亣鍒扮殑瀛楃缂栫爜闂

浠€涔堟槸async鍜宎wait?(椤圭洰涓亣鍒扮殑)

浣跨敤Python杩囩▼涓亣鍒扮殑涓€浜涘潙鍙婂叾瑙e喅鏂规硶锛堟寔缁洿鏂帮級

鍒濊瘑mybatis