20230915
This commit is contained in:
1 parent
83e5aa4218
commit
0f116c7e94
4 files changed
+83
-26
No files matched your search
@@ -1,5 +1,54 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e6dcc663-e0ed-4ea3-b442-11f229f4af94",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 新增体测单位"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "360f0a97-d73d-43f3-9f7a-0f9582103c82",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-09-15T03:53:47.937290Z",
|
||||
"iopub.status.busy": "2023-09-15T03:53:47.936825Z",
|
||||
"iopub.status.idle": "2023-09-15T03:53:47.950180Z",
|
||||
"shell.execute_reply": "2023-09-15T03:53:47.949521Z",
|
||||
"shell.execute_reply.started": "2023-09-15T03:53:47.937254Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pymongo\n",
|
||||
"\n",
|
||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||
"mydb = myclient[\"baogao\"]\n",
|
||||
"mycol = mydb[\"place\"]\n",
|
||||
"\n",
|
||||
"id = 469849\n",
|
||||
"name = \"长炼医院\"\n",
|
||||
"myquery = { \"id\": id }\n",
|
||||
"num = mycol.count_documents(myquery)\n",
|
||||
"if num>0:\n",
|
||||
" print(num)\n",
|
||||
"else:\n",
|
||||
" mydict = { \"id\":id,\"name\": name, }\n",
|
||||
" x = mycol.insert_one(mydict) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dcfbd41f-ca70-4f15-9153-60e6aaac27e8",
|
||||
|
||||
Reference in new issue
Block a user