Skip to content Skip to sidebar Skip to footer

Pandas To Sql Server

I got following code. The problem is I could read data use panda.read_sql, but I could not use the DataFrame.to_sql() function. %matplotlib inline import pandas as pd import pyodbc

Solution 1:

Consider creating a sqlalchemy MSSQL engine and use that in pandas to_sql() con argument:

import sqlalchemy

...
engine = sqlalchemy.create_engine(
               "mssql+pyodbc://user:pwd@server/database",
               echo=False)

data.to_sql('test', con=engine, if_exists='replace')

Post a Comment for "Pandas To Sql Server"