Created
January 21, 2020 21:11
-
-
Save hedonhermdev/4621986f3d4da68e61c1bb668345e773 to your computer and use it in GitHub Desktop.
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
import pickle | |
tables = ['Micro_mstCampus', 'Micro_mstContent', 'Micro_mstContentModule', 'Micro_mstContentModuleItem', 'Micro_mstMicroSite', 'Micro_mstModule', 'Micro_mstTemplate', 'Micro_tblAcademicCampus', 'Micro_tblCampusMenu', 'Micro_tblContentBlock', 'Micro_tblContentModuleMapping', 'Micro_tblGallery', 'Micro_tblMenu', 'Micro_tblModuleRole', 'Micro_tblQuicklinksSEOname', 'Micro_tblSections', 'mstAcademicNavigation', 'mstAcivity', 'mstBanner', 'mstBlock', 'mstCampus', 'mstContent', 'mstContentModule', 'mstContentModuleItem', 'mstModule', 'mstRole', 'mstTemplate', 'mstUser'] | |
with open('db_pickle', 'rb') as pickle_file: | |
db_list = pickle.load(pickle_file) | |
def search_db(search_term): | |
for table in db_list: | |
for row in table: | |
for field in row.values(): | |
if isinstance(field, str): | |
if search_term in field: | |
print(row['intMicroSiteID']) | |
print(tables[db_list.index(table)]) | |
def get_microsite_content(microsite_id): | |
data = [] | |
for table in db_list: | |
for row in table: | |
if 'intMicroSiteID' in row.keys(): | |
if row['intMicroSiteID'] == microsite_id: | |
data.append(row) | |
return data | |
print(get_microsite_content(37)[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment