when i print data from mongo database I am only getting brackets. Pycharm is connected to mongo database.
Pycharm code:
import pymongo
uri=“mongodb://127.0.0.1:27018”
client= pymongo.MongoClient(uri)
database=client[‘norma’]
collection=database[‘students’]
students= [student for student in collection.find({})]
print(students)
output:
/home/tbosss/PycharmProjects/nothing/bin/python /home/tbosss/PycharmProjects/nothing/src/app.py
Process finished with exit code 0
Here the mongo db and collections:
tbosss@tbosss:~$ mongo
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
Server has startup warnings:
2018-06-30T17:30:54.661+0400 I STORAGE [initandlisten]
2018-06-30T17:30:54.661+0400 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-06-30T17:30:54.661+0400 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-06-30T17:30:58.754+0400 I CONTROL [initandlisten]
2018-06-30T17:30:58.754+0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-06-30T17:30:58.754+0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-06-30T17:30:58.754+0400 I CONTROL [initandlisten]
show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
norma 0.000GB
use norma
switched to db norma
show collections
nextra
students
db.students.find()
{ “_id” : ObjectId(“5b3790c5582843c46e144f60”), “name” : “jack”, “class” : “m”, “id” : “789564” }
this is mongod connection and its connected:
2018-06-30T21:04:15.997+0400 I NETWORK [listener] connection accepted from 127.0.0.1:39960 #3 (2 connections now open)
2018-06-30T21:04:15.997+0400 I NETWORK [conn3] received client metadata from 127.0.0.1:39960 conn: { driver: { name: “PyMongo”, version: “3.7.0” }, os: { type: “Linux”, name: “Linux”, architecture: “x86_64”, version: “4.15.0-23-generic” }, platform: “CPython 3.6.5.final.0” }
2018-06-30T21:04:16.501+0400 I NETWORK [conn3] end connection 127.0.0.1:39960 (1 connection now open)
2018-06-30T21:04:16.501+0400 I NETWORK [conn2] end connection 127.0.0.1:39958 (0 connections now open)