Last active
February 27, 2018 07:56
-
-
Save hta218/9535d7be9c5dbbe000cabe7606c375aa to your computer and use it in GitHub Desktop.
Mlab connect guide for c4e course
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoengine | |
#mongodb://<dbuser>:<dbpassword>@ds249798.mlab.com:49798/muadongkhonglanh | |
host = "ds249798.mlab.com" | |
port = 49798 | |
db_name = "muadongkhonglanh" | |
user_name = "admin" | |
password = "admin" | |
def connect(): | |
mongoengine.connect(db_name, host=host, port=port, username=user_name, password=password) | |
def list2json(l): | |
import json | |
return [json.loads(item.to_json()) for item in l] | |
def item2json(item): | |
import json | |
return json.loads(item.to_json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment