Ricercar commited on
Commit
93ce5d3
1 Parent(s): 3fe6653

database fully connected

Browse files
Files changed (1) hide show
  1. pages/Gallery.py +15 -15
pages/Gallery.py CHANGED
@@ -459,24 +459,24 @@ class GalleryApp:
459
  st.session_state.gallery_state = 'graph'
460
 
461
  print('selected_dict: ', st.session_state.selected_dict)
462
- cursor = GALLERY_CONN.cursor()
463
- cursor.close()
464
-
465
- # # save the user selection to database
466
  # cursor = GALLERY_CONN.cursor()
467
- # st.session_state.epoch['gallery'] += 1
468
- # checkouttime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
469
- # # for modelVersion_id in st.session_state.selected_dict[prompt_id]:
470
- # for key, values in st.session_state.selected_dict.items():
471
- # # print('key: ', key, 'values: ', values)
472
- # key_tag = self.promptBook[self.promptBook['prompt_id'] == key]['tag'].unique()[0]
473
- # for value in values:
474
- # query = "INSERT INTO gallery_selections (username, timestamp, tag, prompt_id, modelVersion_id, checkouttime, epoch) VALUES ('{}', '{}', '{}', '{}', {}, '{}', {})".format(st.session_state.user_id[0], st.session_state.user_id[1], key_tag, key, value, checkouttime, st.session_state.epoch['gallery'])
475
- # print(query)
476
- # cursor.execute(query)
477
- # GALLERY_CONN.commit()
478
  # cursor.close()
479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  # get the largest epoch number of this user and prompt
481
  cursor = GALLERY_CONN.cursor()
482
  db_table = 'battle_results' if st.session_state.assigned_rank_mode=='Battle' else 'sort_results'
 
459
  st.session_state.gallery_state = 'graph'
460
 
461
  print('selected_dict: ', st.session_state.selected_dict)
 
 
 
 
462
  # cursor = GALLERY_CONN.cursor()
 
 
 
 
 
 
 
 
 
 
 
463
  # cursor.close()
464
 
465
+ # save the user selection to database
466
+ cursor = GALLERY_CONN.cursor()
467
+ st.session_state.epoch['gallery'] += 1
468
+ checkouttime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
469
+ # for modelVersion_id in st.session_state.selected_dict[prompt_id]:
470
+ for key, values in st.session_state.selected_dict.items():
471
+ # print('key: ', key, 'values: ', values)
472
+ key_tag = self.promptBook[self.promptBook['prompt_id'] == key]['tag'].unique()[0]
473
+ for value in values:
474
+ query = "INSERT INTO gallery_selections (username, timestamp, tag, prompt_id, modelVersion_id, checkouttime, epoch) VALUES ('{}', '{}', '{}', '{}', {}, '{}', {})".format(st.session_state.user_id[0], st.session_state.user_id[1], key_tag, key, value, checkouttime, st.session_state.epoch['gallery'])
475
+ print(query)
476
+ cursor.execute(query)
477
+ GALLERY_CONN.commit()
478
+ cursor.close()
479
+
480
  # get the largest epoch number of this user and prompt
481
  cursor = GALLERY_CONN.cursor()
482
  db_table = 'battle_results' if st.session_state.assigned_rank_mode=='Battle' else 'sort_results'