title: Python to SQL Server Stored Procedure
body: <p>I am trying to call a SQL Server stored procedure from my Python code, using sqlalchemy.  What I'm finding is that no error is raised by the python code and the stored procedure is not executing.</p>
  
  <p>Sample code:</p>
  
  <pre class="lang-py prettyprint-override"><code>def SaveData(self, aScrapeResult):
      sql = "EXECUTE mc.SaveFundamentalDataCSV @pSource='%s',@pCountry='%s',@pOperator='%s',@pFromCountry='%s',@pFromOperator='%s',@pToCountry='%s',@pToOperator='%s',@pSiteName='%s',@pFactor='%s',@pGranularity='%s',@pDescription='%s',@pDataType='%s',@pTechnology = '%s',@pcsvData='%s'"
  
      #   Need to convert the data into CSV
      util = ListToCsvUtil()
      csvValues = util.ListToCsv(aScrapeResult.DataPoints)
  
      formattedSQL = sql % (aScrapeResult.Source ,aScrapeResult.Country,aScrapeResult.Operator ,aScrapeResult.FromCountry ,aScrapeResult.FromOperator ,aScrapeResult.ToCountry ,aScrapeResult.ToOperator ,aScrapeResult.SiteName ,aScrapeResult.Factor ,aScrapeResult.Granularity ,aScrapeResult.Description ,aScrapeResult.DataType ,aScrapeResult.Technology ,csvValues)
  
      DB = create_engine(self.ConnectionString)
      DB.connect()
  
      result_proxy = DB.execute(formattedSQL)
  
      results = result_proxy.fetchall()
  </code></pre>
  
  <p>Examination of formatted SQL yields the following command</p>
  
  <pre class="lang-sql prettyprint-override"><code>EXECUTE mc.SaveFundamentalDataCSV @pSource='PythonTest', @pCountry='UK',
    @pOperator='Operator', @pFromCountry='None', @pFromOperator='None', 
    @pToCountry='None', @pToOperator='None', @pSiteName='None', @pFactor='Factor', 
    @pGranularity='Hourly', @pDescription='Testing from python', 
    @pDataType='Forecast',@pTechnology = 'Electricity',
    @pcsvData='01-Jan-2012 00:00:00,01-Feb-2012 00:15:00,1,01-Jan-2012 00:00:00,01-Feb-2012 00:30:00,2';
  </code></pre>
  
  <p>The various versions and software in use is as follows:
      SQL Server 2008 R2
      Python 2.6.6
      SQLAlchemy 0.6.7</p>
  
  <p>I have tested my stored procedure by calling it directly in SQL Server Management Studio with the same parameters with no problem.</p>
  
  <p>It's worth stating that this point that the Python version and the SQL server version are non-changeable.  I have no strong allegiance to sqlalchemy and am open to other suggestions.</p>
  
  <p>Any advice would be greatly appreciated, more information can be provided if needed.</p>