I have the following query, which works perfectly as long as there is no colon :
character in the search query.
search_query = "http:"
with Session() as session:
search_query_stmt = text(
"""
SELECT count(rowid) as count
FROM post_fts
WHERE post_fts=:search_string
"""
)
count = session.execute(
search_query_stmt, {"search_string": search_query}
).scalar_one()
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: http
[SQL:
SELECT count(rowid) as count
FROM post_fts
WHERE post_fts=?
]
[parameters: ('http:',)]
I have tried the following as per SQLAlchemy documentation
search_query = "http:"
search_query = search_query.replace(':', r'\:')
Which gives the following error
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) fts5: syntax error near "\"
[SQL:
SELECT count(rowid) as count
FROM post_fts
WHERE post_fts match ?;
]
[parameters: ('http\\:',)]