title: pyodbc does not throw on SQL Server error
body: <p>I am trying to use <code>pyodbc</code> (with Python 2.7) to call a stored procedure to insert records into a SQL Server 2012 table. I am passing a temporary table.</p>
  
  <p>I dumped out my sql and when executed through the SQL Server Management console, it generated the following Foreign Key error:</p>
  
  <pre><code>Msg 547, Level 16, State 0, Procedure spInsertBondTickerValues, Line 26
  The INSERT statement conflicted with the FOREIGN KEY constraint "FK__BondTickerValue__756D6ECB".
  The conflict occurred in database "QuantDev", table "dbo.Tickers".
  The statement has been terminated.
  </code></pre>
  
  <p>However, <code>pyodbc</code> did not raise an exception. How would I test the resulting cursor or connection to know that a problem occurred, and how do I get the error message?</p>
  
  <p>Thank you very much.</p>
  
  <p><strong>EDIT</strong> Here is the full sql text:</p>
  
  <pre><code>DECLARE @rawTbl [dbo].TickerValueTableType
  INSERT INTO @rawTbl (Ticker, BBName, LastValue, ValueTime, SourceDescr) VALUES
  ('IBM', 'Equity', 179.230000, '2013-11-01 00:00:00.000000', 'Bloomberg'),
  ('SPX', 'Index', 1803.710000, '2013-12-10 00:00:00.000000', 'Bloomberg')
  EXEC [dbo].spInsertBondTickerValues @rawTbl
  </code></pre>
  
  <p><strong>EDIT 2</strong> Here is the relevant Python code:</p>
  
  <pre><code>def execSQLwithCommit(self, sql):
      cursor = self.conn.cursor()
      cursor.execute(sql)
      self.conn.commit()
  </code></pre>
  
  <p>where the connection has been previously made via</p>
  
  <pre><code>self.conn = pyodbc.connect(app      = appName,
                             driver   = '{SQL Server Native client 11.0}',
                             server   = server,
                             database = db,
                             Trusted_Connection = 'yes')
  </code></pre>