【发布时间】:2017-10-16 02:35:44
【问题描述】:
问题
我已经在我的 MAC OSX 环境中成功启动了mongo shell。我正在为以下链接和文档提供资源,以找出进入数据库、然后是集合、然后在集合中查询文档的简单任务:
Accessing a database 来自 MongoDB 文档,
Accessing a collection and documents,在 Stackoverflow 上,Accessing a collection 来自 Tutorials Point。
我通过PyMongo API 创建并加载了数据库。这成功创建了一个名为UCI-Database 的数据库,一个名为income 的集合,并用来自.csv 文档的一堆文档(行)填充它。
到目前为止..
这些是我的结果...
Blakes-MacBook-Pro:nosql bmc$ mongo 127.0.0.1:27017
MongoDB shell version v3.4.4
connecting to: 127.0.0.1:27017
MongoDB server version: 3.4.4
Server has startup warnings:
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten]
2017-05-16T12:22:10.147-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show dbs
UCI-Database 0.006GB
admin 0.000GB
local 0.000GB
test-database 0.000GB
> use UCI-Database
switched to db UCI-Database
> show collections
income
profiles
>
income 肯定是我创建的集合,用于存储来自 UCI 成人收入存储库的行。如mongo db documentation中所述:
db.collection.find(query, projection)
是查询集合的语法。
我的最佳尝试
> db.UCI-Database.income.find({"age":35})
2017-05-16T16:38:00.846-0400 E QUERY [thread1] ReferenceError: Database is not defined :
@(shell):1:1
>
任何反馈都是有帮助的。
【问题讨论】:
标签: mongodb