title: psycopg2.ProgrammingError: incomplete placeholder: '%(' without ')'
body: <p>I have a few different functions that scrape different tables with pandas, saves each to a dataframe, and saves them to a PostgreSQL database. I am able to successfully scrape and save each table as a dataframe, but I am having a bit of an issue when saving it to SQL. I am trying to do this with something like the below:</p>
  
  <pre><code>from sqlalchemy import create_engine
  
  # Opening sql connection
  engine = create_engine('postgresql://postgres:pw@localhost/name')
  con = engine.connect()
  
  def df1():
      df = scraped_data
      df.to_sql(table_name, con, if_exists='replace')
  df1()
  
  def df2():
      df = scraped_data
      df.to_sql(table_name, con, if_exists='replace')
  df2()
  
  # Closing connection
  con.close()
  </code></pre>
  
  <p>I am able to successfully save <code>df1</code> to SQL, but I get an error when running <code>df2</code>.
  <strong>The only real difference  between the two functions is that they are scraping data from different sources.</strong> Everything else is essentially the same.</p>
  
  <p>I have a couple other functions for other dataframes, but only the first one ever works no matter which order I call the functions.</p>
  
  <p>I keep getting the same error for all of the other functions I call:</p>
  
  <pre><code>psycopg2.ProgrammingError: incomplete placeholder: '%(' without ')'
  </code></pre>
  
  <p>They also linked a page for background on the error: <a href="http://sqlalche.me/e/f405" rel="nofollow noreferrer">http://sqlalche.me/e/f405</a>), although I still don't quite know what to make of it.</p>
  
  <p>I just find it strange how it works for one function but not the others when the only thing that changes is the url that I am scraping from. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am scraping data from the NFL's website. </p>
  
  <p><code>df1</code> iterates through years in a table from <a href="http://www.nfl.com/stats/categorystats?archive=false&amp;conference=null&amp;role=TM&amp;offensiveStatisticCategory=GAME_STATS&amp;defensiveStatisticCategory=null&amp;season=2019&amp;seasonType=REG&amp;tabSeq=2&amp;qualified=false&amp;Submit=Go" rel="nofollow noreferrer">http://www.nfl.com/stats/categorystats?archive=false&amp;conference=null&amp;role=TM&amp;offensiveStatisticCategory=GAME_STATS&amp;defensiveStatisticCategory=null&amp;season=2019&amp;seasonType=REG&amp;tabSeq=2&amp;qualified=false&amp;Submit=Go</a>.</p>
  
  <p><code>df2</code> does a very similar thing but pulls data from <a href="http://www.nfl.com/stats/categorystats?archive=false&amp;conference=null&amp;role=TM&amp;offensiveStatisticCategory=TEAM_PASSING&amp;defensiveStatisticCategory=null&amp;season=2019&amp;seasonType=REG&amp;tabSeq=2&amp;qualified=false&amp;Submit=Go" rel="nofollow noreferrer">http://www.nfl.com/stats/categorystats?archive=false&amp;conference=null&amp;role=TM&amp;offensiveStatisticCategory=TEAM_PASSING&amp;defensiveStatisticCategory=null&amp;season=2019&amp;seasonType=REG&amp;tabSeq=2&amp;qualified=false&amp;Submit=Go</a>.</p>
  
  <p>It looks like that the main difference is that <code>df1</code> uses <code>Pct</code> to represent percentage in a column header whereas <code>df2</code> uses <code>%</code></p>