Better PRAGMA error message, closes #1185

This commit is contained in:
Simon Willison 2021-01-12 14:26:19 -08:00
commit 640ac7071b
3 changed files with 19 additions and 5 deletions

View file

@ -187,7 +187,9 @@ allowed_pragmas = (
disallawed_sql_res = [
(
re.compile(f"pragma(?!_({'|'.join(allowed_pragmas)}))"),
"Statement may not contain PRAGMA",
"Statement contained a disallowed PRAGMA. Allowed pragma functions are {}".format(
", ".join("pragma_{}()".format(pragma) for pragma in allowed_pragmas)
),
)
]