Please guide me how can I pass a very big SQL statement (50 columns) to stmt variable I will use to load into pandas df afterwards?
Here is what I have done:
from sqlalchemy import create_engine, MetaData, Table
import pandas as pd
import pyodbc
engine = create_engine('mssql+pyodbc://uid:pwd@servername/DBName?driver=SQL+Server+Native+Client+11.0')
con = engine.connect()
stmt = select a,
b,
.....
50 columns + where + group by ...
rs = con.execute(stmt)
df = pd.DataFrame(rs.fetchmany(size = 50))
df.columns = rs.keys()
In other words how can I put this large sql statement in ' '? If I will pass it in one row it will be unreadable.
Please advise, thanks in advance!