PyMongo on Azure Cosmos and MongoDB
I created an Azure Cosmos (RU) Serverless database (sharded) with a MongoDB engine and would like to use Python and pymongo to run queries on it. I am not managing to connect to it in any way. I have tested…
I created an Azure Cosmos (RU) Serverless database (sharded) with a MongoDB engine and would like to use Python and pymongo to run queries on it. I am not managing to connect to it in any way. I have tested…
I have 2 collections users and files. A user document looks like this : { "_id": "user1", "name": "John" } A file document looks like this : { "_id": "fileID1", "url": "any_url", "userID": "user1" } I have a list of…
I am attempting to store the name of a MongoDB collection in a variable and refer to that in a query. If I specify the name of the collection without quotes, my query runs, but if I place the name…
If I use pymongo's find_one to query for a specific value then if it's not exist I'll simply get a None but If I query for multiple values using find then I'll get a cursor if at least one of…
Here's an excerpt from pictures MongoDB collection: [ { "_id": "57582b6b", "source": "integration", "url": "https://example.com/images/51/landscapes-polar.xml", "pictures": [ { "name": "pines", "version": "2" }, { "name": "penguins", "version": "1" }, { "name": "pineapple", "version": "7" } ] }, { "_id": "57582b6d",…
I am importing csv using pymongo then inserting it into mongodb but due to some reason all field is in format of string where i was expecting double. Below is python code . def saveToMongo(): print("inside saveToMongo") collection = mydb['country']…
I'm having the following error when I try to execute a get or post in my flask app. mongo:27017: [Errno -2] Name does not resolve (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 657c619ae1e4696f65e708c2, topology_type: Unknown,…
I have a source collection with the following documents indexed on the first 4 fields. [{state: 'NY', city: 'New York', zip: '10000', store: '1234', item: '1234', size: 'L'}, {state: 'NY', city: 'New York', zip: '10000', store: '1234', item: '1234', size:…
coll = MongoClient(uri)[database][collection] cursor = coll.find(query, sort=sort) # I want the query to start executing here! # It doesnt matter to my application if we're stuck here for a couple seconds # ... doc = next(cursor) # this must not…
I have a dataset containing 128 million records stored on a small system hosting an instance of MongoDB. The records are all approximatly 3 kB in size, and they are all of the same shape. (They all contain the same…