Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import pyodbc
- server = "servername"
- db = "databasename"
- username = "username"
- password="password"
- con = pyodbc.connect('Driver={SQL Server Native Client 11.0};SERVER=' + server + ';DATABASE=' + db+';User='+
- username+';Password='+password+';Trusted_Connection=yes;')
- query = "your query"
- df = pd.read_sql(query, con)
- print(df)
Add Comment
Please, Sign In to add comment