File tree Expand file tree Collapse file tree 18 files changed +204
-81
lines changed Expand file tree Collapse file tree 18 files changed +204
-81
lines changed Original file line number Diff line number Diff line change
1
+ root = true
2
+
3
+ [* ]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+ charset = utf-8
7
+ trim_trailing_whitespace = true
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ [* .py ]
12
+ indent_size = 4
13
+
14
+ [Makefile ]
15
+ indent_style = tab
16
+ indent_size = 4
Original file line number Diff line number Diff line change
1
+ name : Test
2
+ on :
3
+ push :
4
+ branches :
5
+ - master
6
+ pull_request :
7
+ branches :
8
+ - master
9
+ jobs :
10
+ build :
11
+ runs-on : ' ${{ matrix.os }}'
12
+ strategy :
13
+ matrix :
14
+ include :
15
+ - os : ubuntu-latest
16
+ python-version : ' 3.8'
17
+ FLASK : 3.0.0
18
+ - os : ubuntu-latest
19
+ python-version : ' 3.8'
20
+ FLASK : 2.3.3
21
+ - os : ubuntu-latest
22
+ python-version : ' 3.8'
23
+ FLASK : 2.2.5
24
+ - os : ubuntu-latest
25
+ python-version : ' 3.8'
26
+ FLASK : 2.1.3
27
+ - os : ubuntu-latest
28
+ python-version : ' 3.8'
29
+ FLASK : 2.0.3
30
+ - os : ubuntu-latest
31
+ python-version : ' 3.8'
32
+ FLASK : 1.1.4
33
+ - os : ubuntu-latest
34
+ python-version : ' 3.8'
35
+ FLASK : 1.0.4
36
+ - os : ubuntu-latest
37
+ python-version : ' 3.9'
38
+ FLASK : 3.0.0
39
+ - os : ubuntu-latest
40
+ python-version : ' 3.9'
41
+ FLASK : 2.3.3
42
+ - os : ubuntu-latest
43
+ python-version : ' 3.9'
44
+ FLASK : 2.2.5
45
+ - os : ubuntu-latest
46
+ python-version : ' 3.9'
47
+ FLASK : 2.1.3
48
+ - os : ubuntu-latest
49
+ python-version : ' 3.9'
50
+ FLASK : 2.0.3
51
+ - os : ubuntu-latest
52
+ python-version : ' 3.9'
53
+ FLASK : 1.1.4
54
+ - os : ubuntu-latest
55
+ python-version : ' 3.9'
56
+ FLASK : 1.0.4
57
+ - os : ubuntu-latest
58
+ python-version : ' 3.10'
59
+ FLASK : 3.0.0
60
+ - os : ubuntu-latest
61
+ python-version : ' 3.10'
62
+ FLASK : 2.3.3
63
+ - os : ubuntu-latest
64
+ python-version : ' 3.10'
65
+ FLASK : 2.2.5
66
+ - os : ubuntu-latest
67
+ python-version : ' 3.10'
68
+ FLASK : 2.1.3
69
+ - os : ubuntu-latest
70
+ python-version : ' 3.10'
71
+ FLASK : 2.0.3
72
+ - os : ubuntu-latest
73
+ python-version : ' 3.10'
74
+ FLASK : 1.1.4
75
+ - os : ubuntu-latest
76
+ python-version : ' 3.10'
77
+ FLASK : 1.0.4
78
+ - os : ubuntu-latest
79
+ python-version : ' 3.11'
80
+ FLASK : 3.0.0
81
+ - os : ubuntu-latest
82
+ python-version : ' 3.11'
83
+ FLASK : 2.3.3
84
+ - os : ubuntu-latest
85
+ python-version : ' 3.11'
86
+ FLASK : 2.2.5
87
+ - os : ubuntu-latest
88
+ python-version : ' 3.11'
89
+ FLASK : 2.1.3
90
+ - os : ubuntu-latest
91
+ python-version : ' 3.11'
92
+ FLASK : 2.0.3
93
+ - os : ubuntu-latest
94
+ python-version : ' 3.11'
95
+ FLASK : 1.1.4
96
+ - os : ubuntu-latest
97
+ python-version : ' 3.11'
98
+ FLASK : 1.0.4
99
+ steps :
100
+ - name : ' Set up Python ${{ matrix.python-version }}'
101
+ uses : actions/setup-python@v2
102
+ with :
103
+ python-version : ' ${{ matrix.python-version }}'
104
+ - uses : actions/checkout@v2
105
+ - run : pip install Flask==$FLASK
106
+ env :
107
+ FLASK : ' ${{ matrix.FLASK }}'
108
+ - run : pip install -r dev_requirements.txt
109
+ - run : pytest
Original file line number Diff line number Diff line change @@ -53,5 +53,8 @@ coverage.xml
53
53
# Sphinx documentation
54
54
docs /_build /
55
55
56
+ # pytest
57
+ .pytest_cache
58
+
56
59
# PyCharm
57
60
.idea /
Original file line number Diff line number Diff line change 1
1
repos :
2
2
- repo : https://github.com/pre-commit/pre-commit-hooks
3
- rev : v4.1 .0
3
+ rev : v4.4 .0
4
4
hooks :
5
5
- id : trailing-whitespace
6
6
- id : end-of-file-fixer
7
7
- id : mixed-line-ending
8
8
args : ['--fix=lf']
9
9
description : Forces to replace line ending by the UNIX 'lf' character.
10
10
- repo : https://github.com/psf/black
11
- rev : 22.1.0
11
+ rev : 23.9.1
12
12
hooks :
13
13
- id : black
14
14
language_version : python3
15
- args : [-t, py310]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,17 +7,17 @@ PYTHON=${VENV_NAME}/bin/python3
7
7
.DEFAULT : help
8
8
help :
9
9
@echo " make dev"
10
- @echo " prepare development environment, use only once"
10
+ @echo " prepare development environment, use only once"
11
11
@echo " make clean"
12
- @echo " delete development environment"
12
+ @echo " delete development environment"
13
13
@echo " make update"
14
- @echo " update dependencies"
14
+ @echo " update dependencies"
15
15
@echo " make test"
16
- @echo " run tests"
16
+ @echo " run tests"
17
17
@echo " make lint"
18
- @echo " run black"
18
+ @echo " run black"
19
19
@echo " make pre-commit"
20
- @echo " run pre-commit hooks"
20
+ @echo " run pre-commit hooks"
21
21
22
22
dev :
23
23
make venv
@@ -41,7 +41,7 @@ test: venv
41
41
${PYTHON} -m pytest
42
42
43
43
lint : venv
44
- $(VENV_NAME ) /bin/black -t py310 - -exclude $(VENV_NAME ) .
44
+ $(VENV_NAME ) /bin/black --exclude $(VENV_NAME ) .
45
45
46
46
pre-commit : venv
47
47
$(VENV_NAME ) /bin/pre-commit
Original file line number Diff line number Diff line change @@ -15,9 +15,8 @@ pip install flask-mysqldb
15
15
```
16
16
17
17
Flask-MySQLdb depends, and will install for you, recent versions of Flask
18
- (0.12.4 or later) and [ mysqlclient] ( https://github.com/PyMySQL/mysqlclient-python ) .
19
- Flask-MySQLdb is compatible with and tested with Python 3.7+. It _ should_ work on any
20
- version from Python 2.7 and up, but is not supported.
18
+ (1.0.4 or later) and [ mysqlclient] ( https://github.com/PyMySQL/mysqlclient ) .
19
+ Flask-MySQLdb is compatible with and tested with Python 3.8+.
21
20
22
21
Next, add a `` MySQL `` instance to your code:
23
22
Original file line number Diff line number Diff line change 1
- black==22.1.0
2
- pre-commit==2.17.0
3
- mysqlclient==1.4.3
1
+ black==23.9.1
2
+ pre-commit==3.4.0
3
+ pytest==7.4.2
4
+ mysqlclient==2.2.0
4
5
5
6
-r requirements.txt
Original file line number Diff line number Diff line change @@ -58,16 +58,16 @@ def __getattr__(cls, name):
58
58
59
59
# General information about the project.
60
60
project = "Flask-MySQLdb"
61
- copyright = "2022 , Alexandre Ferland"
61
+ copyright = "2023 , Alexandre Ferland"
62
62
63
63
# The version info for the project you're documenting, acts as replacement for
64
64
# |version| and |release|, also used in various other places throughout the
65
65
# built documents.
66
66
#
67
67
# The short X.Y version.
68
- version = "1 .0.1 "
68
+ version = "2 .0.0 "
69
69
# The full version, including alpha/beta/rc tags.
70
- release = "1 .0.1 "
70
+ release = "2 .0.0 "
71
71
72
72
# The language for content autogenerated by Sphinx. Refer to documentation
73
73
# for a list of supported languages.
Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ History
96
96
97
97
Changes:
98
98
99
+ - 2.0.0: October 4, 2023
100
+
101
+ - Add support for Flask 3.0.0+.
102
+
99
103
- 1.0.1: February 13, 2022
100
104
101
105
- Fix documentation.
Original file line number Diff line number Diff line change
1
+ 2.0.0
Original file line number Diff line number Diff line change
1
+ from importlib .metadata import version
2
+ flask_major_version = int (version ("flask" )[0 ])
3
+
1
4
import MySQLdb
2
5
from MySQLdb import cursors
3
- from flask import _app_ctx_stack , current_app
6
+ from flask import current_app
7
+ if flask_major_version >= 3 :
8
+ from flask import g
9
+ ctx = g
10
+ else :
11
+ from flask import _app_ctx_stack
12
+ ctx = _app_ctx_stack .top
4
13
5
14
6
- class MySQL ( object ) :
15
+ class MySQL :
7
16
def __init__ (self , app = None ):
8
17
self .app = app
9
18
if app is not None :
@@ -95,13 +104,11 @@ def connection(self):
95
104
unsuccessful.
96
105
"""
97
106
98
- ctx = _app_ctx_stack .top
99
107
if ctx is not None :
100
108
if not hasattr (ctx , "mysql_db" ):
101
109
ctx .mysql_db = self .connect
102
110
return ctx .mysql_db
103
111
104
112
def teardown (self , exception ):
105
- ctx = _app_ctx_stack .top
106
113
if hasattr (ctx , "mysql_db" ):
107
114
ctx .mysql_db .close ()
Original file line number Diff line number Diff line change
1
+ [build-system ]
2
+ requires = [" setuptools" ]
3
+ build-backend = " setuptools.build_meta"
Original file line number Diff line number Diff line change 1
- Flask == 2.3.2
2
- mock == 4.0.3
3
- mysqlclient == 1.4.3
1
+ Flask == 3.0.0
2
+ mock == 5.1.0
3
+ mysqlclient == 2.2.0
Original file line number Diff line number Diff line change
1
+ [metadata]
2
+ name = Flask-MySQLdb
3
+ version = file: flask_mysqldb/VERSION
4
+ author = Alexandre Ferland
5
+ author_email = me@alexferl.com
6
+ url = https://github.com/alexferl/flask-mysqldb
7
+ description = MySQLdb extension for Flask
8
+ long_description = file: README.md
9
+ long_description_content_type = text/markdown
10
+ license = MIT
11
+ classifiers =
12
+ " Environment :: Web Environment"
13
+ " Intended Audience :: Developers"
14
+ " License :: OSI Approved :: MIT License"
15
+ " Operating System :: OS Independent"
16
+ " Programming Language :: Python :: 3.8"
17
+ " Programming Language :: Python :: 3.9"
18
+ " Programming Language :: Python :: 3.10"
19
+ " Programming Language :: Python :: 3.11"
20
+ " Topic :: Software Development :: Libraries :: Python Modules"
21
+
22
+ [options]
23
+ zip_safe = False
24
+ include_package_data = True
25
+ python_requires = >=3.8
26
+ install_requires =
27
+ Flask>=1.0.4
28
+ mysqlclient>=2.2.0
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ from flask import Flask
2
+ from flask_mysqldb import MySQL
3
+
4
+ app = Flask (__name__ )
5
+
6
+
7
+ def test_instantiate ():
8
+ MySQL (app )
You can’t perform that action at this time.
0 commit comments