Questions tagged [mongoalchemy]

MongoAlchemy is a layer on top of the Python MongoDB driver which adds client-side schema definitions, an easier to work with and programmatic query language, and a Document-Object mapper which allows python objects to be saved and loaded into the database in a type-safe way.

46 questions
5
votes
1 answer

how to give structure to python flask application

I am new to python flask Experimenting some end points with MongoDB as shown below in a single file from flask import Flask, request from flask.ext.mongoalchemy import MongoAlchemy app = Flask(__name__) app.config['DEBUG'] =…
dhana lakshmi
  • 847
  • 1
  • 12
  • 29
3
votes
1 answer

Error When Running Author.save() in MongoAlchemy

It now seems that I can connect to the MongoDB Cluster, but when I try to save then I get the error below: TypeError: init() got an unexpected keyword argument 'safe' I have Flask-MongoAlchemy 0.7.1 installed because 0.7.2 doesn't connect at all. I…
OptimusPrime
  • 777
  • 16
  • 25
3
votes
1 answer

How to remove all contents of database using MongoAlchemy

As title suggests, I want to remove all contents of the database. I'm making an application in Python using Flask and MongoAlchemy for database. I have the class People which models the documents. The structure is: class People(db.Document): …
3
votes
1 answer

Avoiding circular imports Python

I know this question have already been answered, but for my application, I can't resolve it. What I'm trying to do is to setup a database using MongoAlchemy instead of using MongoClient. I want to have diffrent scripts for every operation This is my…
3
votes
0 answers

group by in Flask-MongoAlchemy

i stared new project with flask web-framework with mongoDB. i also used database and access data using Flask-MongoAlchemy. i tried work on different query like .all(), .filter_by(), .get() its work nice. but problem is that how to use aggregate…
Kaushik Makwana
  • 2,422
  • 9
  • 31
  • 50
3
votes
4 answers

MongoDB: Embedded users into comments

I cant find "best" solution for very simple problem(or not very) Have classical set of data: posts that attached to users, comments that attached to post and to user. Now i can't decide how to build scheme/classes On way is to store user_id inside…
Tigra
  • 2,611
  • 20
  • 22
2
votes
0 answers

How to resolve: TypeError: __init__() got an unexpected keyword argument 'safe'

I set up a MongoDB database, using MongoAlchemy and Flask in Python. The problem is that when I try to save an object into the database, I get this error, and I didn't found an answer on the internet. The problem seems to be with the parameter safe…
2
votes
1 answer

MongoAlchemy StringField unexpectedly replaced with QueryField?

I've been struggling with an odd bug while working with MongoAlchemy. I have a name = db.StringField() on my Participant model. Most of the time it works fine, but for some reason, the field is occasionally overwritten by a QueryField. If I re-load…
kronosapiens
  • 1,333
  • 1
  • 10
  • 19
2
votes
2 answers

MongoAlchemy embedded documents

Does anyone know how to create a model with an embedded document with mongo alchemy? I've search in the documentation, but there isn't any example about doing that.
danielrvt
  • 10,177
  • 20
  • 80
  • 121
2
votes
1 answer

Creating dynamic documents in Flask-MongoAlchemy

I'm using Flask-MongoAlchemy for a personal project. I have some .cfg input files that I want to parse and make into mongodb document entries. Unfortunately, the .cfg files are flat and I want to make multiple different documents from each file. I'd…
BdON003
  • 131
  • 1
  • 4
1
vote
1 answer

Getting TypeError: __init__() got an unexpected keyword argument 'safe' while connection to mongodb

I wrote the following program to connect to my mongo database from flask import Flask from flask_mongoalchemy import MongoAlchemy app =…
1
vote
0 answers

AttributeError: 'MongoAlchemy' object has no attribute 'insert' MongoDB Flask MongoAlchemy

I am newbie to Flask restplus API's with mongoAlchemy , i am writing the curd opetaion for Flask restplus API's with mongoalchemy but getting the error while saving data to mongoalchemy ** **Traceback (most recent call last): File…
Pandit Biradar
  • 1,777
  • 3
  • 20
  • 35
1
vote
1 answer

Save record from dictionary using MongoAlchemy

My model class for user collection looks like this. class User(UserMixin,db.Document): config_extra_fields = 'ignore' first_name = StringField() last_name = StringField() def get_id(self): return str(self.mongo_id) To…
Codeformer
  • 2,060
  • 9
  • 28
  • 46
1
vote
1 answer

Error When Connecting to MongoDB on Atlas Using Python3 and MongoAlchemy

I am connecting to a cluster set up on MongoDB Atlas using the connection string given on the site. I am running python3 and then run the import db from my module. I get the error "pymongo.errors.InvalidURI: Invalid URI scheme: mongodb+srv" My code…
OptimusPrime
  • 777
  • 16
  • 25
1
vote
0 answers

How to save a string as float or integer in mongodb?

I have a text file containing these line for example 2017-03-14 10:33:56.661 +0800, Number of child: 898 2017-03-14 10:33:56.661 +0800, Volume of water: 86.75 2017-03-14 10:33:56.661 +0800, Size of field: 99.58 2017-03-14 10:34:01.672 +0800, Number…
Fang
  • 824
  • 4
  • 17
  • 32
1
2 3 4