Extract data from SQL Server: https://h3xagn.com
This file contains 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
# get list of history DBs | |
# note: check permission of the user to access 'master' database | |
query = "set nocount on; print 'Database';select name from sys.Databases where name like 'History%'" | |
sqlcmd = f'sqlcmd -S {server} -d ProcessDataDB -U {username} -P {password} -Q "{query}" -s "," -h -1 -W -o "./data/{site}_dbs.csv"' | |
logger.info("-- Getting ProcessDataDB History databases...") | |
os.system(sqlcmd) | |
# get list of historic databases | |
df = pd.read_csv(f"./data/{site}_dbs.csv") | |
logger.info(f"Found {len(df.index)} history DBs.\n") | |
# create list of DBs | |
list_of_dbs = list(df.Database) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment