Last active
November 11, 2016 11:54
-
-
Save alittlesliceoftom/83b027aefbea7ea0c822067de232502c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import sqlalchemy as sa | |
import configparser | |
from os import path | |
configfile = 'config.ini' | |
config = configparser.ConfigParser() | |
config.read(path.dirname(__file__) + '/' + configfile) | |
server = config['Database']['server'] | |
database = config['Database']['Database'] | |
driver = "SQL Server" | |
connection_string = "mssql://{server}/{database}?driver={driver}?trusted_connection=True" | |
"mssql://{server}/{database}?driver={driver}?trusted_connection=True" | |
engine = sa.create_engine(connection_string.format(server=server, database=database, driver=driver)) | |
columns = ['GasFlowDate','LDZ','ALP','DAF','SNCWV','SND' | |
,'WSENS' | |
,'EWCF' | |
,'WAALP' | |
,'WAALP_adjusted'] | |
df = pd.read_sql_table(table_name= 'vwWAALP', schema= 'gas', con = engine, columns =columns) | |
sql_file = open(r'example.sql') | |
sql = sql_file.read() | |
df2 = pd.read_sql(sql = sql, con = engine ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment