擅长:python、mysql、java
<blockquote>
<p>Trying to run in SQL azure so SQL Alchemy is not an easy connection method.</p>
</blockquote>
<p>也许你只需要先克服这个障碍。然后您可以将pandas<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html" rel="nofollow noreferrer">to_sql</a>与<code>fast_executemany=True</code>一起使用。比如说</p>
<pre class="lang-python prettyprint-override"><code>from sqlalchemy import create_engine
#
# ...
#
engine = create_engine(connection_uri, fast_executemany=True)
df.to_sql("table_name", engine, if_exists="append", index=False)
</code></pre>
<p>如果您有一个工作的pyodbc<em>连接字符串</em>,则可以将其转换为SQLAlchemy<em>连接URI</em>,如下所示:</p>
<pre class="lang-python prettyprint-override"><code>connection_uri = 'mssql+pyodbc:///?odbc_connect=' + urllib.parse.quote_plus(connection_string)
</code></pre>