首页 > 数据库 >python链接mongodb的问题

python链接mongodb的问题

时间:2023-10-17 14:57:50浏览次数:35  
标签:monclient python mongodb 数据库 pymongo 链接

python链接mongodb需要指定数据库

import pymongo

monclient = pymongo.MongoClient("mongodb://用户名:密码@192.168.10.200:27017/数据库名")
mondb = monclient["数据库名"]
moncol = mondb["表名"]

网上很多资料都没有指定数据库名,导致后续操作提示没有权限

标签:monclient,python,mongodb,数据库,pymongo,链接
From: https://www.cnblogs.com/studywithallofyou/p/17769685.html

相关文章

  • python 封装日志logging
    #!/usr/bin/python#-*-coding:utf-8-*-importloggingimporttimeimportosclassLog(object):'''封装后的logging'''def__init__(self,logger=None,log_cate='search'):'''......
  • Docker安装Mongodb
    一、宿主机创建目录,存放mongodb配置信息、数据信息mkdir-p/usr/local/mymongo/conf二、参考官方配置文档,配置mongod.conf#在上面的conf目录下,创建mongod.confsystemLog:destination:filepath:/var/log/mongodb/mongod.loglogAppend:truestorage:dbPath:......
  • python练习.4
    问:从键盘输入十个数,统计非负数字的个数和非负数字的和defAyue():arr=[]i=0my_sum=0my_num=0whilei<10:x=int(input("请输入你要统计的数字:"))if(x>=0):arr.append(x)my_sum+=1my......
  • python练习.3
    问:已知abc都是一位数,求当三位数abc加上cba的和为1333时,abc分别的值defAyue():forainrange(10):forbinrange(10):forcinrange(10):ifa*100+b*10+c+c*100+b*10+a==1333:print(a,b,c)print(Ayue(......
  • [907] Merge multiple PDF files into one in Python
    YoucanmergemultiplePDFfilesintooneusingvariousPythonlibraries.OnecommonapproachistousethePyPDF2library,whichallowsyoutomanipulatePDFfiles.Here'sastep-by-stepguidetomergingmultiplePDFsintooneusingPyPDF2:First,......
  • [908] Implementation of the progress bar in Python
    YoucanimplementaprogressbarinPythontovisuallyrepresenttheprogressofataskusingvariouslibraries.Onecommonlyusedlibraryforthispurposeistqdm.Here'showtousetqdmtocreateasimpleprogressbar:First,youneedtoinstall......
  • [910] Copy a file to another directory with a new name in Python
    TocopyafiletoanotherdirectorywithanewnameinPython,youcanusetheshutillibrary.Here'showyoucandoit:importshutil#Specifythesourcefilepathsource_file='path/to/source/file.txt'#Specifythedestinationdirect......
  • python练习.2
    问:求n以内最大的,能被17整除的数.defAyue():a=[]x=int(input("请输入你要测试的数:"))foriinrange(1,x):ifi%17==0:a.append(i)print(f"在1~{x}中的数字能被17整除的数为:{i}")print(a)print(Ayue())......
  • centos 6.10 安装 python3.10.5 和 openssl1.1.1
    centos6.10安装python3.10.5和openssl1.1.1安装opensslcentos6.10自带的openssl版本太老了,要安装1.0.2以上的版本。如果不安装openssl,python的pip无法联网。下载wgethttps://link.juejin.cn/?target=https%3A%2F%2Fwww.openssl.org%2Fsource%2Fopenssl-1.1.1......
  • python request向服务端发送文件
    本篇文章主要介绍1.如何使用pythonrequest向服务端发送文件2.服务端如何接收文件3.服务端如何发送文件如何使用pythonrequest向服务端发送文件request.post可以发送file类型deffoo():local_url="http://127.0.0.1:5000/test_api"file={'video':open("......