Comments (11)
from tinymongo.
I figured it out.
TinyDB which TinyMongo wraps around has slightly different behavior in Python 3.8. So there will need to be some changes to TinyMongo to compensate for this.
There is a class "property" from tinydb that is not working in the newest versions of Python. It requires a fix of the class TinyMongoClient()
property _storage
.
If you want a temporary work-around you can override the class
import tinymongo as tm
import tinydb
class TinyMongoClient(tm.TinyMongoClient):
@property
def _storage(self):
return tinydb.storages.JSONStorage
If you put that code at the top of your module, you can now use TinyMongoClient in the default JSON storage mode.
from tinymongo.
How would one support custom serialization such as the DateTimeSerializer provided with tinymongo using this work around?
The suggested method of supporting datetime objects in tinymongo already overrides this property:
import tinydb
from tinydb_serialization import SerializationMiddleware
import tinymongo as tm
class TinyMongoClient(tm.TinyMongoClient):
@property
def _storage(self):
serialization = SerializationMiddleware()
serialization.register_serializer(tm.serializers.DateTimeSerializer(), 'TinyDate')
return serialization
from tinymongo.
What version of Python are you running? I am seeing this on Python 3.8.2, but not on Python 3.6.9.
from tinymongo.
Maybe you could try the master branch which seems to be TinyDB v4 adopted in this fork: https://github.com/cjboyle/tinymongo
from tinymongo.
That fork works, thanks @davidlatwe . I had hacked the module to work. But my version "locked" TinyMongo to the JSONstorage and would not have supported other middlewares. So your version is definitely welcome.
I did not run the suite of tinymongo tests, but the tests in my project associated with its usage of tinymongo passed on all versions of Python 3.5+
def _storage(self):
"""comments removed"""
return TinyDB.default_storage_class
Are you guys going to release the fork as a 0.2.1 version?
from tinymongo.
What version of Python are you running? I am seeing this on Python 3.8.2, but not on Python 3.6.9.
I was using 3.8.2 but with the workaround it works
from tinymongo.
I have the same problem using python3.7.5
from tinymongo.
from tinymongo.
I actually got this on 3.7.6
The class TinyMongoClient(tm.TinyMongoClient)
solution didn't seem to work for me, but I can't 100% ensure that I didn't mess something else up :)
from tinymongo.
Still works for me FYI
from tinymongo.
Related Issues (20)
- '$nor' operator
- Support subscription-based access to databases and collections
- Use 'filter' instead of 'query' kw parameter name in find and find_one methods
- Releases to Pypi? HOT 2
- pip install error - no file or directory `requirements.txt`
- collection_names() functionality HOT 2
- push to pypi HOT 1
- A small problem in README.md HOT 1
- A problem in README.md HOT 1
- `$in` operator to search tagged documents HOT 3
- collection.drop() not implemented
- ValueError: update only works with $ operators HOT 2
- TinyMongo should enforce using ObjectId
- Multi threading support or use in parallel with tinyrecord HOT 3
- Integration with the ODMs?
- Count example in the docs seems wrong HOT 6
- $unset not implemented
- Code from README does not work
- Updated alernative HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinymongo.