Skip to content

Instantly share code, notes, and snippets.

@hedonhermdev
Created January 21, 2020 21:11
Show Gist options
  • Save hedonhermdev/4621986f3d4da68e61c1bb668345e773 to your computer and use it in GitHub Desktop.
Save hedonhermdev/4621986f3d4da68e61c1bb668345e773 to your computer and use it in GitHub Desktop.
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