{"id":157987,"date":"2020-09-20T00:40:41","date_gmt":"2020-09-19T16:40:41","guid":{"rendered":"http:\/\/4563.org\/?p=157987"},"modified":"2020-09-20T00:40:41","modified_gmt":"2020-09-19T16:40:41","slug":"py3-flask-pymysql-%e5%85%bc%e5%ae%b9%e9%97%ae%e9%a2%98%ef%bc%88use_native_unicode%ef%bc%89-py","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=157987","title":{"rendered":"py3-flask-pymysql \u517c\u5bb9\u95ee\u9898\uff08use_native_unicode\uff09.py"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  py3-flask-pymysql \u517c\u5bb9\u95ee\u9898\uff08use_native_unicode\uff09.py               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yykrlc <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>python &gt;=3.7.9 Flask 1.12 Flask-SQLAlchemy 2.4.4 Flask-WTF 0.14.3 flask_migrate 2.5.3 flask_script 2.0.6 flask_restful 0.3.8 requests redis pymysql 0.10.1 <\/code><\/pre>\n<h5>\u8fde\u63a5 mysql<\/h5>\n<p>MDB_URI = &#8216;mysql+pymysql:\/\/&#8230;&#8230;..<\/p>\n<h5>\u62a5\u9519\u4fe1\u606f:<\/h5>\n<pre><code>TypeError: Invalid argument(s) 'use_native_unicode' sent to create_engine(), using configuration MySQLDialect_mysqldb\/QueuePool\/Engine.  Please check that the keyword arguments are appropriate for this combination of components. <\/code><\/pre>\n<p>\u6d89\u53ca\u6e90\u7801 site-packages\/sqlalchemy\/engine\/strategies.py&#8221;, line 173, in create<\/p>\n<pre><code># all kwargs should be consumed          if kwargs:  # print(kwargs) == {\"use_native_unicode\":''}             raise TypeError(                 \"Invalid argument(s) %s sent to create_engine(), \"                 \"using configuration %s\/%s\/%s.  Please check that the \"                 \"keyword arguments are appropriate for this combination \"                 \"of components.\"                 % (                     \",\".join(\"'%s'\" % k for k in kwargs),                     dialect.__class__.__name__,                     pool.__class__.__name__,                     engineclass.__name__,                 )             )          engine = engineclass(pool, dialect, u, **engine_args) <\/code><\/pre>\n<p>db = SQLAlchemy() flask_sqlalchemy\/<strong>init<\/strong>.py<\/p>\n<pre><code># \u9ed8\u8ba4 use_native_unicode=True def __init__(self, app=None, use_native_unicode=True, session_options=None,                  metadata=None, query_class=BaseQuery, model_class=Model,                  engine_options=None): <\/code><\/pre>\n<p>\u662f\u4e0d\u662f flask_sqlalchemy \u548c sqlalchemy \u517c\u5bb9\u95ee\u9898\uff0c\u9664\u4e86\u6539\u6e90\u7801\u8fd8\u6709\u522b\u7684\u89e3\u51b3\u65b9\u6cd5\u5417\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3380090\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rogwan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u662f\u7248\u672c\u95ee\u9898\uff0c\u628a\u7248\u672c\u53f7\u7a0d\u5fae\u964d\u4f4e\u4e00\u70b9\u8bd5\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3380091\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Kobayashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u662f\u4e8c\u8005\u517c\u5bb9\u95ee\u9898\uff0c\u6211\u770b\u4e86\u4e00\u773c\u5728 flask_sqlalchemy \u5728 3.0 (dev) \u4e2d\u53bb\u9664\u4e86\u8fd9\u4e2a\u521d\u59cb\u5316\u53c2\u6570\u3002\u731c\u6d4b\u662f\u4e0a\u6e38 sqlalchemy \u66f4\u65b0\u4e86\uff0c\u8fd9\u4e2a\u53c2\u6570\u4e0d\u80fd\u7528\u4e86\uff1f<\/p>\n<p>flask_sqalchemy \u4f9d\u8d56\u5199\u5f97\u6bd4\u8f83\u5bbd\u677e\uff0cinstall_requires=[&#8220;Flask&gt;=0.10&#8221;, &#8220;SQLAlchemy&gt;=0.8.0&#8221;].<\/p>\n<p>\u5efa\u8bae\u628a sqlalchemy \u7248\u672c\u5217\u51fa\u6765\uff0c\u9010\u6b65\u5f80\u56de\u964d\u8bd5\u8bd5\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>py3-flask-pymysql&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/157987"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157987"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/157987\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157987"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}