Giter Site home page Giter Site logo

tinymongo's People

Contributors

cj-wright avatar davidlatwe avatar fopina avatar jjonesatmoog avatar lockefox avatar marlysson avatar ramuta avatar rochacbruno avatar schapman1974 avatar slightlynybbled avatar sunbit avatar tech4him1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinymongo's Issues

Error when loading database file

When using the example code in Python 3.8 i get this error :

Traceback (most recent call last):
  File "C:/Users/loicn/backend_db.py", line 7, in <module>
    db = connection.my_tiny_database
  File "C:\Users\loicn\AppData\Local\Programs\Python\Python38\lib\site-packages\tinymongo\tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  File "C:\Users\loicn\AppData\Local\Programs\Python\Python38\lib\site-packages\tinymongo\tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  File "C:\Users\loicn\AppData\Local\Programs\Python\Python38\lib\site-packages\tinymongo\tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded

Process finished with exit code 1

push to pypi

The current github version is so much better than what's on PyPI.
Really should be pushed soon.

Integration with the ODMs?

This project looks great. Any idea or plans on allowing it to be the backend for higher level libraries like MongoEngine, uMongo?

It seems like it might be possible to just replace MongoClient() with TinyMongoClient() in some way and potentially ignore things like create index requests if that isn't supported.

Code from README does not work

Tries running code from "examples" section, got RecursionError

from tinymongo import TinyMongoClient
>>> connection = TinyMongoClient()
>>> db = connection.my_tiny_database
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/whatever/my_project/.venv/lib/python3.8/site-packages/tinymongo/tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  File "/Users/whatever/my_project/.venv/lib/python3.8/site-packages/tinymongo/tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  File "/Users/whatever/my_project/.venv/lib/python3.8/site-packages/tinymongo/tinymongo.py", line 73, in __getattr__
    return TinyMongoDatabase(name, self._foldername, self._storage)
  [Previous line repeated 987 more times]
RecursionError: maximum recursion depth exceeded

TinyMongo should enforce using ObjectId

TinyMongo should enforce using ObjectId, just like MongoDB does.

The bson ObjectId can't be used directly, because it doesn't accept TinyDB ids (they are too short). So either make the TinyDB id the right size, or implement own ObjectId:

class ObjectId:
    def __new__(cls, *args, **kwargs):
        return str(args[0])

pip install error - no file or directory `requirements.txt`

The way setup.py is written, the project will install correctly directly, and straight from source, but I have an issue using tinymongo with test_requires

error: [Errno 2] No such file or directory: 'requirements.txt'

Though the requirements are passed correctly inside the dist (tinymongo.egg-info/requires.txt) this isn't accessible at setup time. And when pytest tries to get set up, it fails because of requirements.txt

Hard-writing the requirements.txt into setup.py (rather than reading from requirements.txt) would fix this. Or also checking the .egg-info path might do the trick too.

$unset not implemented

By the way, I'm a big fan of this project as the noSQL alternative to SQLite project.

I kept wondering why when I used "$unset" nothing was changed. Then I checked the tests, and then finally drilled into the code and noticed that "$unset" is not implemented.

Are there any plans for adding this?

ValueError: update only works with $ operators

TinyMongo allows you to update a document like this:

collection.update_one({"_id": "fh98h43f89fh4fh"}, {"some_field": "some update"})

But on the real MongoDB database (on mLab) I get this error: ValueError: update only works with $ operators.

So I needed to change the code like this:

collection.update_one({"_id": "fh98h43f89fh4fh"}, {"$set": {"some_field": "some update"}})

This also works on TinyMongo and it is a more appropriate way to update a document. TinyMongo should follow the MongoDB/pymongo behaviour and throw the same error in the first case.

`$in` operator to search tagged documents

I have a document like this

{
 '_id': '3c7df42e91c611e7bf575ce0c5482b4b',
 'authors': ['Bruno Rocha'],
 'authors_slug': ['bruno-rocha'],
 'category': 'python/flask',
 'date': datetime.datetime(2017, 9, 4, 20, 10, 26),
 'published': True,
 'slug': 'simple-login-extension-for-flask',
 'tags': ['python', 'flask', 'pythonplanet', 'pyplanet', 'new'],
 'title': 'Simple Login Extension for Flask',
}

It has a 'tags': ['python', 'flask', 'pythonplanet', 'pyplanet', 'new'] and I have more documents with tag python

When I search using {'tags': 'python'}

col.find({'tags': 'python'}).count()
25.09 22:19:22 tinymongo.tinymongo DEBUG    query to parse2: {'tags': 'python'}
25.09 22:19:22 tinymongo.tinymongo DEBUG    query: {'tags': 'python'} prev_query: None
25.09 22:19:22 tinymongo.tinymongo DEBUG    conditions: tags python
25.09 22:19:22 tinymongo.tinymongo DEBUG    c: QueryImpl('==', ('tags',), 'python')
25.09 22:19:22 tinymongo.tinymongo DEBUG    new query item2: QueryImpl('==', ('tags',), 'python')
0

Ok that is expected so lets use {'$in': 'python'}

col.find({'tags': {'$in': 'python'}}).count()
25.09 22:20:34 tinymongo.tinymongo DEBUG    query to parse2: {'tags': {'$in': 'python'}}
25.09 22:20:34 tinymongo.tinymongo DEBUG    query: {'tags': {'$in': 'python'}} prev_query: None
25.09 22:20:34 tinymongo.tinymongo DEBUG    conditions: tags {'$in': 'python'}
25.09 22:20:34 tinymongo.tinymongo DEBUG    c: None
25.09 22:20:34 tinymongo.tinymongo DEBUG    query: {'$in': 'python'} prev_query: tags
25.09 22:20:34 tinymongo.tinymongo DEBUG    conditions: $in python
25.09 22:20:34 tinymongo.tinymongo DEBUG    c: None
25.09 22:20:34 tinymongo.tinymongo DEBUG    new query item2: None
0

or with a list: {'$in': ['python', 'flask']}

col.find({'tags': {'$in': ['python', 'flask']}}).count()
25.09 22:21:09 tinymongo.tinymongo DEBUG    query to parse2: {'tags': {'$in': ['python', 'flask']}}
25.09 22:21:09 tinymongo.tinymongo DEBUG    query: {'tags': {'$in': ['python', 'flask']}} prev_query: None
25.09 22:21:09 tinymongo.tinymongo DEBUG    conditions: tags {'$in': ['python', 'flask']}
25.09 22:21:09 tinymongo.tinymongo DEBUG    c: None
25.09 22:21:09 tinymongo.tinymongo DEBUG    query: {'$in': ['python', 'flask']} prev_query: tags
25.09 22:21:09 tinymongo.tinymongo DEBUG    conditions: $in ['python', 'flask']
25.09 22:21:09 tinymongo.tinymongo DEBUG    c: None
25.09 22:21:09 tinymongo.tinymongo DEBUG    query: {'tags': 'python'} prev_query: None
25.09 22:21:09 tinymongo.tinymongo DEBUG    conditions: tags python
25.09 22:21:09 tinymongo.tinymongo DEBUG    c: QueryImpl('==', ('tags',), 'python')
25.09 22:21:09 tinymongo.tinymongo DEBUG    query: {'tags': 'flask'} prev_query: None
25.09 22:21:09 tinymongo.tinymongo DEBUG    conditions: tags flask
25.09 22:21:09 tinymongo.tinymongo DEBUG    c: QueryImpl('==', ('tags',), 'flask')
25.09 22:21:09 tinymongo.tinymongo DEBUG    new query item2: QueryImpl('or', frozenset({('==', ('tags',), 'python'), ('==', ('tags',), 'flask')}))
0

I checked the source code and currently the $in operator only works in the reverse way, it works currently to match a single field against an array of possibilities. But not to check an array against a single value or array.

A small problem in README.md

Your code:
record_id = collection.insert_one({'username': 'admin', 'password': 'hello world'}) user_info = collection.find_one({'_id': record_id})

But record_id is an <tinymongo.results.InsertOneResult object>

I read some code. I think it should be
record_id = collection.insert_one({'username': 'admin', 'password': 'hello world'}).inserted_id

Tested in Python 3.6.1.

Count example in the docs seems wrong

Hello! Thanks for the great lib ^_^

I've been testing a bit the examples,
and found out that

# Getting the total of records
db.users.count()

in the README doesn't work for me, while db.users.find().count() does.

Am I doing something wrong or is the docs to fix?
Thank you,
have the greatest day

ๆŠฅ้”™(self)

def count():
    if self.table is None: self.buildTable()
    return self.table.count(self.lastcond)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.