title: Python try except to drop or create table in sql server
body: <p>I am using pyodbc to create or drop table. And I wrote a function to drop table if table has already existed. Please look at my syntax below</p>
  
  <pre><code>try:
      cur.execute('Drop table {}'.format(table_name))
  except ProgrammingError:
      cur.execute(create_table)
  </code></pre>
  
  <p>However, I got error message :</p>
  
  <pre><code>&lt;ipython-input-79-fe0fe29a1e8e&gt; in upload_to_SQL(file_name, skiprows, table_name)
   26     try:
   27         cur.execute('Drop table {}'.format(table_name))
  ---&gt;28  except ProgrammingError:
   29         cur.execute(create_table)
   30 
  
  NameError: name 'ProgrammingError' is not defined
  </code></pre>
  
  <p>I confirm that <strong>ProgrammingError</strong> is the error message if I drop a table didn't exist in the sql server. Anyone have idea how to revise this? </p>