-
Notifications
You must be signed in to change notification settings - Fork 32
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
Error when loading database file #58
Comments
What version of Python are you running? I am seeing this on Python 3.8.2, but not on Python 3.6.9. |
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 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. |
Maybe you could try the master branch which seems to be TinyDB v4 adopted in this fork: https://github.com/cjboyle/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+
Are you guys going to release the fork as a 0.2.1 version? |
I was using 3.8.2 but with the workaround it works |
I have the same problem using python3.7.5 |
Thanks for the information.
…On Sun, May 31, 2020 at 12:37 AM Marcos Diniz ***@***.***> wrote:
I have the same problem using python3.7.5
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6KUBCKL7IE6GK5H6PV7X3RUHNIXANCNFSM4M75KOOQ>
.
--
Jeff Muday
Instructional Technology Analyst
Wake Forest University
1834 Wake Forest Rd.
Winston Hall Rm. 27
Winston Salem, NC 27106
mudayja @ wfu . edu
p 336.758.6171
f 336.758.6004
|
I actually got this on 3.7.6 |
I have used this extensively-- so I have a high level of confidence it
works and will continue to work even if Schapman upgrades the code.
Make sure you are importing tinymongo and tinydb. In this case we are
"overriding" the TinyMongoClient class property import to ensure we have
the correct return. It might look a little awkward, but it achieves the
same effect as Conner Boyle's fork (Thank you David Lai for pointing this
out)
######### code starts here
import tinymongo as tm
import tinydb
class TinyMongoClient(tm.TinyMongoClient):
@Property
def _storage(self):
return tinydb.storages.JSONStorage
############ code ends here
ALTERNATELY... You could just work with the forked version from Conner
Boyle's github repository.
$ pip uninstall tinymongo
$ pip install git+https://github.com/cjboyle/tinymongo
The only "gotcha" of doing it this way is that you cannot uninstall
CJBoyle's version with a "pip uninstall", you have to remove it the old
fashioned way of going into the environment packages and deleting the
directory.
…On Wed, Jun 17, 2020 at 2:59 PM Selwyn-Lloyd McPherson < ***@***.***> wrote:
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 :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6KUBCOTUYWTKDVDZFO3MLRXEHBDANCNFSM4M75KOOQ>
.
--
Jeff Muday
Instructional Technology Analyst
Wake Forest University
1834 Wake Forest Rd.
Winston Hall Rm. 27
Winston Salem, NC 27106
mudayja @ wfu . edu
p 336.758.6171
f 336.758.6004
|
Still works for me FYI |
How would one support custom serialization such as the DateTimeSerializer provided with tinymongo using this work around?
|
When using the example code in Python 3.8 i get this error :
The text was updated successfully, but these errors were encountered: