Upload mongo.py
Browse files
mongo.py
CHANGED
|
@@ -11,10 +11,29 @@ def get_mongo_col(col="config_beta"):
|
|
| 11 |
return col
|
| 12 |
|
| 13 |
# 拿到 collection 对象
|
| 14 |
-
|
| 15 |
|
| 16 |
-
db = col.database # 或者直接用 client["dashboard"]
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
return col
|
| 12 |
|
| 13 |
# 拿到 collection 对象
|
| 14 |
+
collection = get_mongo_col() # 默认 col="config_beta"
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
+
query = {"name": "txt2txt_price_config"}
|
| 18 |
+
projection = {"_id": 0, "data": 1}
|
| 19 |
+
|
| 20 |
+
doc = collection.find_one(query, projection)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if doc:
|
| 24 |
+
data_value = doc.get("data")
|
| 25 |
+
print(data_value)
|
| 26 |
+
else:
|
| 27 |
+
print("未找到 name 等于 txt2txt_price_config 的记录")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# 查询单条文档
|
| 31 |
+
# doc = collection.find_one(query, projection)
|
| 32 |
+
|
| 33 |
+
# db = col.database # 或者直接用 client["dashboard"]
|
| 34 |
+
|
| 35 |
+
# # 列出所有集合名
|
| 36 |
+
# collections = db.list_collection_names()
|
| 37 |
+
# print("当前 database 下的集合:", collections)
|
| 38 |
+
|
| 39 |
+
# ['mp_collection', 'system.profile', 'mtxx_odz_aimr_im_chat_order_label_aggregate', 'xx_expose_history', 'aibeauty_trigger', 'mtxx_odz_aimr_im_chat_order', 'my_music_history', 'aibeauty_data_beta', 'my_music_history_count14', 'xx_area_mapping', 'aibeauty_trigger_beta', 'aibeauty_feedback', 'counters', 'xx_music_history', 'aibeauty_directive_beta', 'gd_history', 'message_spark_list_beta', 'my_expose', 'aibeauty_directive', 'xx_material_history', 'message_tongyi_list', 'aibeauty_im_msg', 'xx_formula_save_top100', 'aibeauty_title_stat', 'aibeauty_data', 'config', 'message_wenxin_list_beta', 'im_chat_msg_type', 'mp_neg_feedback', 'my_click', 'my_material_use_info', 'message_list_beta', 'message_pangu_list', 'aibeauty_data_history', 'my_search_history', 'mp_live', 'aibeauty_feedback_beta', 'aibeauty_top_data', 'message_wenxin_list', 'mp_expose', 'aibeauty_title_beta', 'aibeauty_data_history_beta', 'mtxx_odz_aimr_im_chat_order_label', 'related_history', 'xx_new_user', 'mht_rec_path', 'xx_feed_count', 'sdk_adz_aigc_chatgpt_info', 'aibeauty_top_data_gid_room_id', 'video_4k_transcoder', 'my_material_info', 'xx_music_material_category', 'mp_click', 'my_banner_history', 'webui_task_beta', 'config_beta', 'mht_dynamic_info', 'aibeauty_top_data_prompt_roomlist', 'my_search_history_count14', 'my_material_info_30', 'webui_record_beta', 'my_material_history', 'message_list', 'my_tmpl_history', 'aibeauty_title_stat_beta', 'message_pangu_list_beta', 'xx_dislike', 'my_music_history_count30', 'my_recommend_view', 'nlp_timeliness', 'blackflow_history', 'aibeauty_title', 'aibeauty_top_data_beta', 'message_spark_list', 'message_tongyi_list_beta', 'click_history']
|