You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

Contact info

Tan | ts864@cornell.edu

BioHPC

BioHPC is used to host our production database. To connect to the database, first make sure that you are connected to your Cornell VPN and then use this connection string.

mongodb://mongodbuser:2TQFTnrQYb2yQFhYqnCUGxesurPISnXwhsFHyfP2cr4ILQeUk1@cbsujohnson.biohpc.cornell.edu:8001/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false

MongoDB Atlas

Introduction

MongoDB Atlas is a web application supported by MongoDB team. It simplifies the deployment and maintenance of MongoDB servers on cloud and provides convenient GUI for server configuration and data manipulation.

Pricing

Each instance of database server offers 512 MB of free storage but there is no limit on the number of instances.

Setup

Dependencies

PyMongo 3.6

dnspython 2.0

Joining the project

First, join the project on MongoDB Atlas. To do so, ask someone already in the project to invite you using your Cornell email address.

Once you joined the project, go to https://account.mongodb.com/account/login and login using your email address. You should see a project dashboard similar to the one below.

Connecting to the database

In MongoDB Atlas, a database server instance is called a cluster. To connect to a server, click the "connect" button in the corresponding cluster (usually Cluster0) and you will see the dialog below.

If you are connecting using Python (or other programming languages), choose "Connect your application" option and select your language and the version of your connection library (PyMongo for Python).

Copy the connection string and replace <password> with "uV0spJEn3Q9cbUw6" and <dbname> with the target database's name. Then you can establish connection in your code using the connection string.

Example

 You can test your connection using the following code snippet.

from pymongo import MongoClient
client = MongoClient('mongodb+srv://admin:uV0spJEn3Q9cbUw6@cluster0.etmbn.mongodb.net/test?retryWrites=true&w=majority')
db = client.test
db.initial_insert.insert_one({'your field':'your value'})

which connects to the test database and inserts an entry into the initial_insert collection. You can check if your new data has been successfully inserted by logging into the dashboard and clicking the "collection" button of the cluster.

Known Setup Issues

certificate verify failed: unable to get local issuer certificate

This error can happen when running the code above. It's because the server requires connections to be run on TLS/SSL but Python has no root CA certificate installed by default. To solve this, if you are using MacOS, run

/Applications/Python\ 3.7/Install\ Certificates.command

(Python version may differ) on your terminal.

  • No labels