Itter from some odbc join with pandas table without csv

I have basic information in a pandas DataFrame. I need to join it with some reference tables that I have access through a pyobbc connection. Is there a way to get a sql result set in a pandas DataFrame without first writing the result to csv?

It seems like this is an extra exit in csv and in DataFrame.

+1
pandas pyodbc
Nov 26 '12 at 17:39
source share
1 answer

I got pyodbc to work with my SQL Server instance, then, with some help from this thread , I got sql return to load the dataframe.

I already made a pyodbc connection and then made a call.

 import pyodbc import pandas.io.sql as psql cnxn = pyodbc.connect(your_connection_info) cursor = cnxn.cursor() sql = ("""SELECT * FROM Source""") df = psql.frame_query(sql, cnxn) cnxn.close() 

df should return your framework. The hardest part for me was getting pyodbc up and running - I had to use freetds , and it took a lot of trial and error to work.

+5
Nov 26 '12 at 18:23
source share



All Articles