import pandas.io.sql as sql import pyodbc conn = pyodbc.connect(driver='{SQL Server}', host='192.168.201.100,1433', database='test', user='id', password='pass') begin_dt = "'20150501'" end_dt = "'20150516'" sql_string = ''' select x, y from tbl_a and regdate >= %s and regdate < %s ''' % (begin_dt, end_dt) result = sql.read_sql(sql_string, conn) print result slope, intercept, r_value, p_value, stderr = stats.linregress(result.amt, result.dau) print slope, intercept, r_value, p_value, stderr