3 ms·
Using tools such as sqlmagic or pyodbc for ipython (below) you can let the sql database perform most of the heavy lifting of getting "raw" result sets into a da
by pweissbrod 9y ago
Using tools such as sqlmagic or pyodbc for ipython (below) you can let the sql database perform most of the heavy lifting of getting "raw" result sets into a dataframe and then perform some lighter, possibly more ptyhon-idiomatic tweaks to the data once the focused set is loaded in-memory.
def getdataframe(sql):
try:
connection = pyodbc.connect("DSN=myDSN", autocommit=True)
return pandas.read_sql(sql, connection)
except Exception as e:
print repr(e)
finally:
connection.close()