title: Writing python (pandas) Data Frame to SQL Database Error
body: <p>I am trying to put a python data frame to a MS SQL DB and I am getting the following error</p>
  
  <p><strong>FUNCTION</strong></p>
  
  <pre><code>def put_to_server(df):       # df is a pandas data frame
     server="KORNBSVM04\MSSQLSERVER2012"
     Driver="{SQL Server}"
     userid=''
     pswd=''
     cnxn = pyodbc.connect(driver=Driver, server=server, database="CIHOTLINE",uid=userid, pwd=pswd)
     cur=cnxn.cursor()
     df.to_sql(name='dbo.test',con=cnxn)
  </code></pre>
  
  <p><strong>ERROR</strong></p>
  
  <pre><code> File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 950, in to_sql
  index_label=index_label)
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 475, in to_sql
  index_label=index_label)
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 1084, in to_sql
  index_label=index_label)
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 543, in __init__
  if self.pd_sql.has_table(self.name):
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 1094, in has_table
  return len(self.execute(query).fetchall()) &gt; 0
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 1041, in execute
  raise_with_traceback(ex)
  File "C:\Python27\lib\site-packages\pandas\io\sql.py", line 1030, in execute
  cur.execute(*args)
  pandas.io.sql.DatabaseError: Execution failed on sql: SELECT name FROM sqlite_master WHERE type='table' AND name='dbo.test';
  </code></pre>