Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error when using MongoBackend #67

Open
ShawnXu opened this issue Jun 6, 2016 · 1 comment
Open

getting error when using MongoBackend #67

ShawnXu opened this issue Jun 6, 2016 · 1 comment
Labels

Comments

@ShawnXu
Copy link

ShawnXu commented Jun 6, 2016

I was glad to find out that blitzdb offers a MongoDB wrapper so I tried it out. Unfortunately I couldn't get it to work

>>> backend = blitzdb.MongoBackend('mongo://127.0.0.1:27017/', True)
>>> doc = blitzdb.Document({'name': 'Shawn'})
>>> doc.save(backend)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Users\shawn\AppData\Local\Programs\Python\Python35-32\lib\site-packages\blitzdb-0.2.12-py3.5.egg\blitzdb\document.py", line 449, in save
    return backend.save(self)
  File "c:\Users\shawn\AppData\Local\Programs\Python\Python35-32\lib\site-packages\blitzdb-0.2.12-py3.5.egg\blitzdb\backends\mongo\backend.py", line 151, in save
    return self.save_multiple([obj])
  File "c:\Users\shawn\AppData\Local\Programs\Python\Python35-32\lib\site-packages\blitzdb-0.2.12-py3.5.egg\blitzdb\backends\mongo\backend.py", line 144, in save_multiple
    self.db[collection].save(attributes)
TypeError: string indices must be integers

I'm sure my mongodb server is running fine. I suppose the usage against the MongoDB backend should be the same. There isn't much documentation on read docs. Am I doing something wrong?

@adewes adewes added the doing label Jun 6, 2016
@bieli
Copy link

bieli commented May 8, 2017

I suggesting look at this example: https://github.com/adewes/blitzdb/blob/master/blitzdb/backends/mongo/backend.py#L51

First You need connection from pymongo and second from MongoDB you get database object expected by first argument in blitzdb.MongoBackend() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants