sql like query

102 views
Skip to first unread message

Kasmadi

unread,
Jul 27, 2018, 2:35:14 AM7/27/18
to PyMySQL Users
how to use like query pymysql ?
my code
sql="... LIKE %s"
not result

INADA Naoki

unread,
Jul 27, 2018, 2:51:49 AM7/27/18
to pymysq...@googlegroups.com
1) cursor.execute("SELECT ... LIKE %s", ("%HELLO",))
2) cursor.execute("SELECT ... LIKE '%%HELLO')

(2) is not documented intentionally. Other driver (e.g. MySQL Connector/Python)
doesn't support it.
> --
> You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
INADA Naoki <songof...@gmail.com>

Kasmadi

unread,
Jul 27, 2018, 3:02:21 AM7/27/18
to PyMySQL Users
thanks for your answer, but i have same error "unsupported operand type(s) for %: 'tuple' and 'tuple'", how to resolve it, thanks 

INADA Naoki

unread,
Jul 27, 2018, 3:08:15 AM7/27/18
to pymysq...@googlegroups.com
You should show code and real error + stacktrace when you ask such questions.
Reply all
Reply to author
Forward
0 new messages