title: Can I use pyodbc executemany with sql stored procedure?
body: <p>I need to write a lot of data from pandas dataframes to MS-SQL tables (1000's or even more rows at once).</p>
  <p>I'm using <code>pyodbc executmany</code> with <code>fast_executemany=True</code>, otherwise it takes hours for each table. Now the IT guys want me to start working with stored procedures instead of direct access to the DB for security reasons.</p>
  <p>The problem is that from what I've seen, SQL is, how to say, not as flexible as python, and I have to declare every variable passed to the SP, so I don't see how I can pass the SP with <code>df.values.tolist()</code> as I'm doing today with the <code>executemany</code> function on direct access to the DB.</p>
  <p>For example, let's say I have a dataframe df:</p>
  <h2>id    name    salary</h2>
  <p>1     Josh    10000</p>
  <p>2     Michael  5000</p>
  <p>3     Sara     8000</p>
  <p>Today I would use:</p>
  <pre><code>cursor.fast_executemany = True
  insert_str = &quot;INSERT INTO [%s].[%s] VALUES (?, ?, ?)&quot;
  cursor.executemany(insert_str % (scheme, table), df.values.tolist()])
  </code></pre>
  <p>And all the dataframe would be inserted to the table at once (and fast). But, is doesn't seem possible to do the same with calling an SP.</p>
  <p>Is there a way to use <code>pyodbc executemany</code> with stored procedures?</p>