软件下载吧文章资讯

分类分类

MongoDB执行mongoexport时的异常及分析(数字类型的查询)

2024-03-08 08:50作者:下载吧

概述

mongoexport命令行用于数据的导出,默认导出的文件格式为JSON格式。当然也可以指定特定的文件格式。

语法

C:mongobin>mongoexport -help
options:
  –help                  produce help message
  -v [ –verbose ]        be more verbose (include multiple times for more
                          verbosity e.g. -vvvvv)
  -h [ –host ] arg       mongo host to connect to ( <set name>/s1,s2 for sets)
  –port arg              server port. Can also use –host hostname:port
  –ipv6                  enable IPv6 support (disabled by default)
  -u [ –username ] arg   username
  -p [ –password ] arg   password
  –dbpath arg            directly access mongod database files in the given
                          path, instead of connecting to a mongod  server –
                          needs to lock the data directory, so cannot be used
                          if a mongod is currently accessing the same path
  –directoryperdb        if dbpath specified, each db is in a separate
                          directory
  -d [ –db ] arg         database to use
  -c [ –collection ] arg collection to use (some commands)
  -f [ –fields ] arg     comma separated list of field names e.g. -f name,age
  –fieldFile arg         file with fields names – 1 per line
  -q [ –query ] arg      query filter, as a JSON string
  –csv                   export to csv instead of json
  -o [ –out ] arg        output file; if not specified, stdout is used
  –jsonArray             output to a json array rather than one object per
                          Line

说明:

引言

今天在用mongoexport导出满足一定条件下的数据时,遇到了一个报错,现纪录下来,并且针对此错误对MongoDB 的 数字类型做了进一步的学习。

背景 及 报错信息

今天接到一个业务需求,需要从MongoDB 数据库 order集合中导出符合以下条件的数据:

db.qqwj_order.find({“Source”:NumberInt(“21″),”Batch”:”支付中的订单提醒:2018/9/5″,”MsgContent”:/还未完成在线付款/})

通过MongoDB 客户端工具 【NoSQLBooster for MongoDB】查询检查,语句执行正常,显示相应记录数为 15265。

MongoDB执行mongoexport时的异常及分析(数字类型的查询)

导出数据使用mongoexport命令,执行命令如下:

/data/mongodb/mongobin344/bin/mongoexport -h 172.X.X.XXX –port 端口 –db 数据库 -u 账号 -p ‘密码’ –authenticationDatabase 认证数据库 –type=csv -c qqwj_order -f MsgContent,REC_CreateTime -q ‘{ “Source”:NumberInt(“21″),”Batch”:”支付中的订单提醒:2018/9/5″,”MsgContent”:/还未完成在线付款/}’ -o /data/mongodb_back/sms.csv

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消