How to use Python to Encode a JSON File into MongoDB BSON Documents

Introduction This tutorial will explain how to use Python to encode JSON files into MongoDB BSON documents using the BSON library. The library is useful for parsing JSON objects from files, strings, a Python dictionary or list and can also convert dictionaries and lists into JSON strings. As Python 2.7 has been deprecated, Python version … Continued

Elasticsearch Python Index Example

Introduction Elasticsearch is the lightning speed search and analytics power engine that helps businesses just like yours discover solutions to their use cases. Couple it with Python, the programming language that streamlines system integration, and you have the most sensible way to index a document in Elasticsearch. This tutorial shows you how to index an … Continued

Use Python To Query MongoDB Documents In A Terminal Window

Introduction If you’re storing data in MongoDB, you may want to query for documents from a Python script. Fortunately, this is a simple task to accomplish. In this article, we’ll show you how to pass MongoDB query strings to a Python script from a terminal window. The script will then return a query response of … Continued

How to use Python to Check if an Index Exists for a MongoDB Collection

Introduction Indexing document fields in a MongoDB collection helps to facilitate search queries, making the searches run more efficiently. This tutorial will show how to determine if a MongoDB index exists with the Python driver. This tutorial will also touch on how to manage a MongoDB collection’s indexes in the Compass GUI. Prerequisites A good … Continued

Use Python To Query Elasticsearch In A Terminal Window

Introduction If you’re using Elasticsearch to store and search your data, it’s important to know that you can query your data from a number of different sources. One way to to query documents is to pass an Elasticsearch index and a query term to a Python script from a terminal window, having Python return an … Continued

How to Fix the RequestsDependencyWarning Elasticsearch with Python Import Error

Introduction This tutorial will cover how to fix the requests dependency warning error while importing the Elasticsearch library for Python. There is a bug that sometimes throws a RequestsDependencyWarning error message when attempting to import the library for Elastic’s official Elasticsearch Python client. This error message is due to some versions of the Elasticsearch client … Continued

How To Setup A MongoDB App Using The Flask Framework

Introduction This tutorial will explain how to use the Flask micro-framework to create a MongoDB restful API in Python using the flask_pymongo library. The Flask app for MongoDB serves as a lightweight wrapper for the PyMongo client driver needed for creating a python HTTP client for MongoDB. This Flask-PyMongo tutorial will provide examples for installing … Continued

How To Use Python To Download Photos From An Elasticsearch Index

Introduction This tutorial will demonstrate how to store an image on an Elasticsearch index and embed its raw encoded data and the EXIF meta data into an image using Python’s PIL and Piexif libraries. Examples will include how to export an elasticsearch image with python, export elasticsearch documents with python, convert base64 to pil images, … Continued

How To Sort MongoDB Documents In A Collection Using Python

Introduction When a call is made to query documents, MongoDB returns a pymongo.cursor.Cursor object containing data about the query’s results. This cursor object has an attribute method called sort() that allows for the sorting of MongoDB documents and the data to be iterated and organized either alphabetically or numerically, making the iteration process more efficient. … Continued

How To Find And Replace Or Change MongoDB Documents In Python

Introduction To find MongoDB documents Python and replace MongoDB documents Python, you use the replace_one() method. It’s a process that reconstructs a document, therefore, you must have the document’s entire data to pass to the method. This comes in handy when you really need a “do over” for a document. That is to say, your … Continued

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.