From 2d5fd94132accb2733833eb273d755803a99794c Mon Sep 17 00:00:00 2001
From: "David J. Malan" <malan@harvard.edu>
Date: Mon, 14 Oct 2024 20:39:22 -0400
Subject: [PATCH 1/2] adds support for VACUUM

---
 setup.py        | 2 +-
 src/cs50/sql.py | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index 6fd6cfa..1817b95 100644
--- a/setup.py
+++ b/setup.py
@@ -18,5 +18,5 @@
     package_dir={"": "src"},
     packages=["cs50"],
     url="https://github.com/cs50/python-cs50",
-    version="9.3.4"
+    version="9.4.0"
 )
diff --git a/src/cs50/sql.py b/src/cs50/sql.py
index cbbd3d2..a133293 100644
--- a/src/cs50/sql.py
+++ b/src/cs50/sql.py
@@ -177,6 +177,7 @@ def execute(self, sql, *args, **kwargs):
             "SELECT",
             "START",
             "UPDATE",
+            "VACUUM",
         }
 
         # Check if the full_statement starts with any command
@@ -378,7 +379,7 @@ def teardown_appcontext(exception):
                 )
 
                 # Check for start of transaction
-                if command in ["BEGIN", "START"]:
+                if command in ["BEGIN", "START", "VACUUM"]:  # cannot VACUUM from within a transaction
                     self._autocommit = False
 
                 # Execute statement
@@ -389,7 +390,7 @@ def teardown_appcontext(exception):
                     connection.execute(sqlalchemy.text("COMMIT"))
 
                 # Check for end of transaction
-                if command in ["COMMIT", "ROLLBACK"]:
+                if command in ["COMMIT", "ROLLBACK", "VACUUM"]:  # cannot VACUUM from within a transaction
                     self._autocommit = True
 
                 # Return value

From f81a0a3920d90296537843d45683ec0b5d70171b Mon Sep 17 00:00:00 2001
From: "David J. Malan" <malan@harvard.edu>
Date: Mon, 14 Oct 2024 20:40:31 -0400
Subject: [PATCH 2/2] fixes raw strings

---
 src/cs50/sql.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cs50/sql.py b/src/cs50/sql.py
index a133293..81905bc 100644
--- a/src/cs50/sql.py
+++ b/src/cs50/sql.py
@@ -329,12 +329,12 @@ def execute(self, sql, *args, **kwargs):
                 sqlparse.tokens.Literal.String,
                 sqlparse.tokens.Literal.String.Single,
             ]:
-                token.value = re.sub("(^'|\s+):", r"\1\:", token.value)
+                token.value = re.sub(r"(^'|\s+):", r"\1\:", token.value)
 
             # In identifier
             # https://www.sqlite.org/lang_keywords.html
             elif token.ttype == sqlparse.tokens.Literal.String.Symbol:
-                token.value = re.sub('(^"|\s+):', r"\1\:", token.value)
+                token.value = re.sub(r'(^"|\s+):', r"\1\:", token.value)
 
         # Join tokens into statement
         statement = "".join([str(token) for token in tokens])