所以我遇到了一个非常类似的问题,通过做
跟随。
遵循[SQL炼金术]
[文件](http://docs.sqlalchemy.org/en/latest/dialogs/mssql.html#模块-
sqlalchemy.dialones.mssql语言.pyodbc)我发现我可以使用我的pyodbc连接
字符串如下:
# Python 2.ximport urllibparams = urllib.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATAbase=test;UID=user;PWD=password")engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)# Python 3.ximport urllibparams = urllib.parse.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATAbase=test;UID=user;PWD=password")engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)# using the above logic I just did the followingparams = urllib.parse.quote_plus('DRIVER={SQL Server};SERVER=HARRISONS-THINK;DATAbase=LendApp;Trusted_Connection=yes;')app.config['SQLALCHEMY_DATAbase_URI'] = "mssql+pyodbc:///?odbc_connect=%s" % params
This then caused an additional error because I was also using Flask-Migrate
and apparently it doesn’t like % in the connection URI. So I did some more
digging and found this post.
I then changed the following line in my
./migrations/env.pyfile
From:
from flask import current_appconfig.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATAbase_URI'))
To:
from flask import current_appdb_url_escaped = current_app.config.get('SQLALCHEMY_DATAbase_URI').replace('%', '%%')config.set_main_option('sqlalchemy.url', db_url_escaped)
在做了所有这些之后,我能够进行迁移,一切看起来都像
它现在工作正常。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)