Skip to Main Content
Python Programming Blueprints
book

Python Programming Blueprints

by Daniel Furtado, Marcus Pennington
February 2018
Intermediate to advanced content levelIntermediate to advanced
456 pages
9h 56m
English
Packt Publishing
Content preview from Python Programming Blueprints

Adding the database helper class

Now that we have implemented the function that will fetch the exchange rate information from fixer.io, we need to add the class that will retrieve and save the information we fetched into our MongoDB.

So, let's go ahead and create a file called db.py inside the currency_converter/currency_converter/core directory; let's add some import statements:

  from pymongo import MongoClient

The only thing we need to import is the MongoClient. The MongoClient will be responsible for opening a connection with our database instance.

Now, we need to add the DbClient class. The idea of this class is to serve as a wrapper around the pymongo package functions and provide a simpler set of functions, abstracting some of the repetitive ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intelligent Projects Using Python

Intelligent Projects Using Python

Santanu Pattanayak, Manohar Swamynathan
Flask Blueprints

Flask Blueprints

Joël Perras
Matplotlib for Python Developers - Second Edition

Matplotlib for Python Developers - Second Edition

Aldrin Yim, Claire Chung, Allen Yu

Publisher Resources

ISBN: 9781786468161Supplemental Content