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 1
1
import MySQLdb
2
+ import MySQLdb .cursors
2
3
from flask import _app_ctx_stack , current_app
3
4
4
5
@@ -30,6 +31,7 @@ def init_app(self, app):
30
31
app .config .setdefault ('MYSQL_USE_UNICODE' , True )
31
32
app .config .setdefault ('MYSQL_CHARSET' , 'utf8' )
32
33
app .config .setdefault ('MYSQL_SQL_MODE' , None )
34
+ app .config .setdefault ('MYSQL_CURSORCLASS' , None )
33
35
34
36
if hasattr (app , 'teardown_appcontext' ):
35
37
app .teardown_appcontext (self .teardown )
@@ -73,6 +75,9 @@ def connect(self):
73
75
if current_app .config ['MYSQL_SQL_MODE' ]:
74
76
kwargs ['sql_mode' ] = current_app .config ['MYSQL_SQL_MODE' ]
75
77
78
+ if current_app .config ['MYSQL_CURSORCLASS' ]:
79
+ kwargs ['cursorclass' ] = getattr (MySQLdb .cursors , current_app .config ['MYSQL_CURSORCLASS' ])
80
+
76
81
return MySQLdb .connect (** kwargs )
77
82
78
83
@property
You can’t perform that action at this time.
0 commit comments