嘿,所以我有以下代码,我在从MS Sql Server表中提取表的地方运行,运行了一些代码,然后尝试将其重新导入同一数据库内的另一个表中。在spyder中运行
它一直运行到最后,但是当我
select * from pythontest
在SQL Server上,该表为空白。有什么不正常的地方吗?
## From SQL to DataFrame Pandas
import pandas as pd
import pyodbc
import mysql.connector
from sqlalchemy import create_engine
sql_conn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=njsrvnav1;"
"Database=cornerstone;"
"Trusted_Connection=yes;")
query = "SELECT [c1], [c2], [c3] from projectmaster"
df = pd.read_sql(query, sql_conn)
df = df[:100]
con = create_engine('mssql+pyodbc://username:pword@serverName:1433/cornerstone?driver=SQL+Server+Native+Client+11.0')
df.to_sql('dbo.pythontest', con, if_exists='replace')
con.dispose()
答案 0 :(得分:0)
尝试使用//support.website.com/script.php?id=6...
:
pymysql