文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 1591e93f by 李景熙

添加“数据单”表

parent 3ebad4b7
from pymongo import MongoClient
host = '47.92.1.107' # 服务器url
client = MongoClient(host, 8081) # 服务器端口
db = client.da # 数据库=test
db.authenticate("admin", "admin") # 账号密码
collection_data_set = db.dataset
# 添加用户的数据单
def insert_data_set(data_set):
try:
re = collection_data_set.insert_one(data_set)
return re
except Exception as e:
print(e)
return None
# 查找某用户对应的数据单列表
def find_data_set(user_id):
try:
results = collection_data_set.find({'user_id':user_id})
dictionary = []
for i in results:
i.pop("_id")
dictionary.append(i)
return dictionary
except Exception as e:
print(e)
return None
# 删除某数据单列表
def delete_data_set(_id):
try:
result = collection_data_set.find_one({'data_set_id':_id})
collection_data_set.delete_one({'data_set_id': _id})
return result
except Exception as e:
print(e)
return None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment