1

I am working with mongoalchemy version 0.21 and unable to figure out where to specify mongodb connection string.

The last documentation available is for 0.14 and even in that, I couldn't figure out where one can specify MongoDB connection string. It only mentions about database string.

I am new to pymongo itself and wanted to adopt mongoalchemy for field validation and cleaner code within flask framework.

Has anybody used the latest version? If yes, could you please share a sample code.

Most of the examples that I got refer to older versions where one used to have camel case MongoAlchemy import from flask.ext.pymongo

comiventor
  • 3,922
  • 5
  • 50
  • 77

1 Answers1

1
from mongoalchemy.session import Session

session = Session.connect('mydb', host='mongodb://uname:pwd@hostname:port/mydb')
# Internally, mongoalchemy passes the host parameter to MongoClient

session.save(collection_name(param=1))

I got this from one of the Issue discussion in the mongoalchemy repo. Also came to know there are some issue with partial doc updates. :(

comiventor
  • 3,922
  • 5
  • 50
  • 77