Reputation: 119
So with https://www.eversql.com/sql-syntax-check-validator/ I checked my SQL, which is correct. But when I try to use it I get a ValueError: unsupported format character 'v' (0x76) at index 5519
! I believe this is because my query is quite large (>15.000 characters), but I'm not sure. Searching around didn't reveal any problems with large queries for others, although most of the webpages dated from before 2016 so I'm not sure if they're still relevant.
Here's the code I use to execute the query:
def run(self, stmt):
with self.db.connect() as conn:
conn.execute(stmt)
The query is
REPLACE INTO table VALUES ...
Upvotes: 2
Views: 1213
Reputation: 123494
Use SQLAlchemy's text()
function to prepare the statement for execution:
from sqlalchemy import text
# …
def run(self, stmt):
with self.db.begin() as conn:
conn.execute(text(stmt))
That will prevent the SQL wildcard character %
from being misinterpreted as a Python string formatting character.
Upvotes: 5