title: python SQL statement with variables without using %s
body: <p>I hope i can be clear about my problem. thank you :)</p>
  
  <p>I'm using impala connection (library: from impala.dbapi import connect).</p>
  
  <p>In order to run a query i'm using the execute command:
  <code>cursor.execute(query.value,  (year_var, month_var,day_var))</code></p>
  
  <p>Generally - it works just fine, also with variables. the problem begins when i use a SQL LIKE statement (e.g. like '%seo' - which contain %s in it).</p>
  
  <p>The 1st argument (query.value) is a string:</p>
  
  <pre><code>create table bi_db.search_terms as
  select search_query,search_contain,count(*) searches
  from (
  select  search_query,
  case when lower(search_query) like '%logo%' then 'logo'
       when lower(search_query) like '%google%' then 'google'
       when lower(search_query) like '%facebook%' then 'facebook'
       when lower(search_query) like '%instagram%' then 'instagram'
       when lower(search_query) like '%etsy%' then 'etsy'
       when lower(search_query) like '%seo%' then 'seo'
       when lower(search_query) like '%social media%' then 'social media'
       else 'else' end as search_contain
  from traffic_db.traffic_parq   a
  where year = %s AND month = %s AND day = %s AND  controller = 'search'  and action in ('gigs','users')        
  and search_query is not null and search_query&lt;&gt;'' ) t
  group by search_query,search_contain
  </code></pre>
  
  <p>the second argument of the cursor.execute (e.g. (year_var, month_var,day_var)) refer to %s i'm putting on the query i run in order to use dynamic variables.</p>
  
  <p>** The problem is that the python thinks it has 5 arguments instead of only 3. that caused because i have <code>%seo</code> and <code>%social</code> in the LIKE statments ** </p>
  
  <p>Anyone encountered this kind of problem? know how to solve it?</p>
  
  <p>Many thanks!</p>