@@ -177,6 +177,7 @@ def execute(self, sql, *args, **kwargs):
177177 "SELECT" ,
178178 "START" ,
179179 "UPDATE" ,
180+ "VACUUM" ,
180181 }
181182
182183 # Check if the full_statement starts with any command
@@ -328,12 +329,12 @@ def execute(self, sql, *args, **kwargs):
328329 sqlparse .tokens .Literal .String ,
329330 sqlparse .tokens .Literal .String .Single ,
330331 ]:
331- token .value = re .sub ("(^'|\s+):" , r"\1\:" , token .value )
332+ token .value = re .sub (r "(^'|\s+):" , r"\1\:" , token .value )
332333
333334 # In identifier
334335 # https://www.sqlite.org/lang_keywords.html
335336 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 )
337338
338339 # Join tokens into statement
339340 statement = "" .join ([str (token ) for token in tokens ])
@@ -378,7 +379,7 @@ def teardown_appcontext(exception):
378379 )
379380
380381 # Check for start of transaction
381- if command in ["BEGIN" , "START" ]:
382+ if command in ["BEGIN" , "START" , "VACUUM" ]: # cannot VACUUM from within a transaction
382383 self ._autocommit = False
383384
384385 # Execute statement
@@ -389,7 +390,7 @@ def teardown_appcontext(exception):
389390 connection .execute (sqlalchemy .text ("COMMIT" ))
390391
391392 # Check for end of transaction
392- if command in ["COMMIT" , "ROLLBACK" ]:
393+ if command in ["COMMIT" , "ROLLBACK" , "VACUUM" ]: # cannot VACUUM from within a transaction
393394 self ._autocommit = True
394395
395396 # Return value
0 commit comments