sql-like

Python String Formats with SQL Wildcards and LIKE

Python String Formats with SQL Wildcards and LIKE Question: I’m having a hard time getting some sql in python to correctly go through MySQLdb. It’s pythons string formatting that is killing me. My sql statement is using the LIKE keyword with wildcards. I’ve tried a number of different things in Python. The problem is once …

Total answers: 8

Python SQLite parameter substitution with wildcards in LIKE

Python SQLite parameter substitution with wildcards in LIKE Question: I am attempting to use a parametrized LIKE query with Python’s Sqlite library as below: self.cursor.execute(“select string from stringtable where string like ‘%?%’ and type = ?”, (searchstr,type)) but the ? inside of the wildcard is not being evaluated leaving me with this error: “sqlite3.ProgrammingError: Incorrect …

Total answers: 2