File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 11import MySQLdb
2+ import MySQLdb .cursors
23from flask import _app_ctx_stack , current_app
34
45
@@ -30,6 +31,7 @@ def init_app(self, app):
3031 app .config .setdefault ('MYSQL_USE_UNICODE' , True )
3132 app .config .setdefault ('MYSQL_CHARSET' , 'utf8' )
3233 app .config .setdefault ('MYSQL_SQL_MODE' , None )
34+ app .config .setdefault ('MYSQL_CURSORCLASS' , None )
3335
3436 if hasattr (app , 'teardown_appcontext' ):
3537 app .teardown_appcontext (self .teardown )
@@ -73,6 +75,9 @@ def connect(self):
7375 if current_app .config ['MYSQL_SQL_MODE' ]:
7476 kwargs ['sql_mode' ] = current_app .config ['MYSQL_SQL_MODE' ]
7577
78+ if current_app .config ['MYSQL_CURSORCLASS' ]:
79+ kwargs ['cursorclass' ] = getattr (MySQLdb .cursors , current_app .config ['MYSQL_CURSORCLASS' ])
80+
7681 return MySQLdb .connect (** kwargs )
7782
7883 @property
You can’t perform that action at this time.
0 commit comments