Python again

https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb
https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb

https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb

{ “cells”: [ { “cell_type”: “code”, “execution_count”: null, “metadata”: {}, “outputs”: [], “source”: [ “\”C:\\Users\\jingh\\Documents\\resultFile.xlsx\”\n”, “\n” ] }, { “cell_type”: “code”, “execution_count”: 5, “metadata”: {}, “outputs”: [ { “name”: “stdout”, “output_type”: “stream”, “text”: [ “Index([‘addresses’, ‘account’], dtype=’object’)\n” ] } ], “source”: [ “import pandas as pd\n”, “\n”, “df = pd.read_excel(‘C:/Users/jingh/Documents/resultFile.xlsx’, sheet_name = ‘Sheet1’)\n”, “\n”, “print(df.columns)\n”, “\n”, “from sqlalchemy import create_engine\n”, “\n”, “server = ‘LAPTOP-S1V0PRKL’\n”, “\n”, “database = ‘pythontest’\n”, “\n”, “sqlcon = create_engine(‘mssql+pyodbc://@ ‘ + server + ‘/’ + database + ‘?trusted_connection=yes&driver=ODBC+Driver+17+for+SQL+Server’)\n”, “\n”, “df.to_sql(‘table_test20200207’, con = sqlcon, schema = ‘schema_test’, if_exists = ‘append’)” ] }, { “cell_type”: “code”, “execution_count”: null, “metadata”: {}, “outputs”: [], “source”: [] } ], “metadata”: { “kernelspec”: { “display_name”: “Python 3”, “language”: “python”, “name”: “python3” }, “language_info”: { “codemirror_mode”: { “name”: “ipython”, “version”: 3 }, “file_extension”: “.py”, “mimetype”: “text/x-python”, “name”: “python”, “nbconvert_exporter”: “python”, “pygments_lexer”: “ipython3”, “version”: “3.7.3” } }, “nbformat”: 4, “nbformat_minor”: 2 }

https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb?short_path=cfd42d5

<a href="https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb">https://github.com/jxu5BI/notebook_files_for_blog/blob/master/write_excel_file_to_SQL_server_table.ipynb</a>

https://github.com/jxu5BI/try1/blob/master/notebook_files_for_blog/write_excel_file_to_SQL_server_table.ipynb

 &lt;/p&gt;
&lt;!-- /wp:paragraph --&gt;

&lt;!-- wp:preformatted --&gt;
&lt;pre class="wp-block-preformatted"&gt;&lt;strong&gt;import&lt;/strong&gt; &lt;strong&gt;pandas&lt;/strong&gt; &lt;strong&gt;as&lt;/strong&gt; &lt;strong&gt;pd&lt;/strong&gt;

df = pd.read_excel('C:/Users/jingh/Documents/resultFile.xlsx', sheet_name = 'Sheet1')

print(df.columns)

&lt;strong&gt;from&lt;/strong&gt; &lt;strong&gt;sqlalchemy&lt;/strong&gt; &lt;strong&gt;import&lt;/strong&gt; create_engine

server = 'LAPTOP-S1V0PRKL'

database = 'pythontest'

sqlcon = create_engine('mssql+pyodbc://@ ' + server + '/' + database + '?trusted_connection=yes&amp;amp;driver=ODBC+Driver+17+for+SQL+Server')

df.to_sql('table_test20200207', con = sqlcon, schema = 'schema_test', if_exists = 'append')&lt;/pre&gt;
&lt;!-- /wp:preformatted --&gt;

&lt;!-- wp:paragraph --&gt;
&lt;p&gt; 

import pandas as pd

df = pd.read_excel('C:/Users/jingh/Documents/resultFile.xlsx', sheet_name = 'Sheet1')

print(df.columns)

from sqlalchemy import create_engine

server = 'LAPTOP-S1V0PRKL'

database = 'pythontest'

sqlcon = create_engine('mssql+pyodbc://@ ' + server + '/' + database + '?trusted_connection=yes&driver=ODBC+Driver+17+for+SQL+Server')

df.to_sql('table_test20200207', con = sqlcon, schema = 'schema_test', if_exists = 'append')

now let’s see what I got

Leave a Reply

Your email address will not be published. Required fields are marked *