import os
import pymongo
import time


client = pymongo.MongoClient("mongodb://admin:readgazer_2022@81.69.98.171:27017/test")
# print(client.list_database_names())   # 查看所有数据库名字

# 清空数据库
# client["Qiangwei"].command("dropDatabase")

# 选择(创建)数据库
db = client["Qiangwei"]  
# 选择(创建)集合
docs_col = db.docs


localtime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 

path=r"./static/doc/qiangwei"
namelist=os.listdir(path)


# # 导入数据————文本内容
for i in range(len(namelist)):
  
    upper = "admin"
   
    # query = {"_id": str(i), "content": fp_c.read(), "highlight": highlight}
    query = {"_id":str(i),"filename": namelist[i], "upper": upper,"upload_time":localtime,"kind":"5A","status":"release","upload_time":localtime,"frequency":0}
    id = docs_col.insert_one(query).inserted_id
    # print(id)
# print(docs_col.find()[0])


