pyquocca 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyquocca-0.2.2 → pyquocca-0.2.3}/PKG-INFO +1 -1
- {pyquocca-0.2.2 → pyquocca-0.2.3}/pyproject.toml +1 -1
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/gunicorn.py +5 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/mysql.py +11 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/pgsql.py +12 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/.gitignore +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/.python-version +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/Dockerfile +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/README.md +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/bump.zsh +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/bump_examples.zsh +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/docker-compose.yml +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/__init__.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/envvars.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/flags.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/header_utils.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/logging.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/py.typed +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/pyquocca/xssbot.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/test_app/main.py +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/test_app/sqlimports-mysql/init.sql +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/src/test_app/sqlimports-pgsql/init.sql +0 -0
- {pyquocca-0.2.2 → pyquocca-0.2.3}/uv.lock +0 -0
|
@@ -91,12 +91,18 @@ def fetch_all(connection: Connection, sql: str, values=None) -> list[dict[str, A
|
|
|
91
91
|
return list(cursor.fetchall())
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
class UninitialisedError(Exception):
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
94
98
|
class FlaskMySQL:
|
|
95
99
|
"""Flask extension to add basic DB transaction usage to requests using MySQL. Each request gets a new connection
|
|
96
100
|
and automatically commits or rolls back (if there is an unhandled exception) the entire transaction at
|
|
97
101
|
the end of the request.
|
|
98
102
|
"""
|
|
99
103
|
|
|
104
|
+
app: Optional[Flask]
|
|
105
|
+
|
|
100
106
|
def __init__(self, name: str = "mysql", app: Optional[Flask] = None):
|
|
101
107
|
self.name = name
|
|
102
108
|
|
|
@@ -104,9 +110,14 @@ class FlaskMySQL:
|
|
|
104
110
|
self.init_app(app)
|
|
105
111
|
|
|
106
112
|
def init_app(self, app: Flask):
|
|
113
|
+
self.app = app
|
|
107
114
|
app.teardown_request(self._teardown_request)
|
|
108
115
|
|
|
109
116
|
def _get_connections_dict(self):
|
|
117
|
+
if self.app is None:
|
|
118
|
+
raise UninitialisedError(
|
|
119
|
+
"This Flask extension has not been initialised with .init_app() yet (required for auto-commit)."
|
|
120
|
+
)
|
|
110
121
|
# g._mysql_connections is a dictionary of database names to connections.
|
|
111
122
|
try:
|
|
112
123
|
assert type(g._mysql_connections) is dict
|
|
@@ -123,12 +123,18 @@ def fetch_all(
|
|
|
123
123
|
return cursor.fetchall()
|
|
124
124
|
|
|
125
125
|
|
|
126
|
+
class UninitialisedError(Exception):
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
|
|
126
130
|
class FlaskPostgres(Generic[T]):
|
|
127
131
|
"""Flask extension to add basic DB transaction usage to requests using Postgres. Each request gets a connection
|
|
128
132
|
from the pool and automatically commits or rolls back (if there is an unhandled exception) the entire
|
|
129
133
|
transaction at the end of the request.
|
|
130
134
|
"""
|
|
131
135
|
|
|
136
|
+
app: Optional[Flask]
|
|
137
|
+
|
|
132
138
|
def __init__(
|
|
133
139
|
self,
|
|
134
140
|
name: str = "postgres",
|
|
@@ -146,9 +152,15 @@ class FlaskPostgres(Generic[T]):
|
|
|
146
152
|
self.init_app(app)
|
|
147
153
|
|
|
148
154
|
def init_app(self, app: Flask):
|
|
155
|
+
self.app = app
|
|
149
156
|
app.teardown_request(self._teardown_request)
|
|
150
157
|
|
|
151
158
|
def _get_connections_dict(self):
|
|
159
|
+
if self.app is None:
|
|
160
|
+
raise UninitialisedError(
|
|
161
|
+
"This Flask extension has not been initialised with .init_app() yet (required for auto-commit)."
|
|
162
|
+
)
|
|
163
|
+
|
|
152
164
|
# g._pgsql_connections is a dictionary of database names to connections.
|
|
153
165
|
try:
|
|
154
166
|
assert type(g._pgsql_connections) is dict
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|