pumpkin
pumpkin

Reputation: 31

Can I import a table from SQL Server (=MS SQL) into a Python / Pandas data frame?

I am using Matlab and its 'datasets', and R and its 'dataframes'.

I am thinking of using Python but I need an equivalent data-storing format. Extension 'Pandas' for Python has a class called dataframe which is similar.

Now I would like to be able to send a query to a SQL Server and store the result of that query in a Panda Dataframe

e.g.: newDataFrame = GetDataFrameFromSQLServer('SELECT * from schema.table',sqlConnection)

I had the impression that Pandas only talks to SQLite. Is that the case?

Upvotes: 3

Views: 1739

Answers (1)

tshauck
tshauck

Reputation: 21574

I believe pandas can handle any reading from any DB API v2.0 compliant data source. Have a look at pandas.io.sql(link) for a bunch of functions that facilitate this.

One thing to note, is that writing to a database requires a "flavor" where that flavor defaults to sqlite, but in the write_frame definition possible values are {'sqlite', 'mysql', 'oracle'}.

Upvotes: 1

Related Questions