@@ -177,6 +177,7 @@ def execute(self, sql, *args, **kwargs):
177
177
"SELECT" ,
178
178
"START" ,
179
179
"UPDATE" ,
180
+ "VACUUM" ,
180
181
}
181
182
182
183
# Check if the full_statement starts with any command
@@ -328,12 +329,12 @@ def execute(self, sql, *args, **kwargs):
328
329
sqlparse .tokens .Literal .String ,
329
330
sqlparse .tokens .Literal .String .Single ,
330
331
]:
331
- token .value = re .sub ("(^'|\s+):" , r"\1\:" , token .value )
332
+ token .value = re .sub (r "(^'|\s+):" , r"\1\:" , token .value )
332
333
333
334
# In identifier
334
335
# https://www.sqlite.org/lang_keywords.html
335
336
elif token .ttype == sqlparse .tokens .Literal .String .Symbol :
336
- token .value = re .sub ('(^"|\s+):' , r"\1\:" , token .value )
337
+ token .value = re .sub (r '(^"|\s+):' , r"\1\:" , token .value )
337
338
338
339
# Join tokens into statement
339
340
statement = "" .join ([str (token ) for token in tokens ])
@@ -378,7 +379,7 @@ def teardown_appcontext(exception):
378
379
)
379
380
380
381
# Check for start of transaction
381
- if command in ["BEGIN" , "START" ]:
382
+ if command in ["BEGIN" , "START" , "VACUUM" ]: # cannot VACUUM from within a transaction
382
383
self ._autocommit = False
383
384
384
385
# Execute statement
@@ -389,7 +390,7 @@ def teardown_appcontext(exception):
389
390
connection .execute (sqlalchemy .text ("COMMIT" ))
390
391
391
392
# Check for end of transaction
392
- if command in ["COMMIT" , "ROLLBACK" ]:
393
+ if command in ["COMMIT" , "ROLLBACK" , "VACUUM" ]: # cannot VACUUM from within a transaction
393
394
self ._autocommit = True
394
395
395
396
# Return value
0 commit comments