I am creating an app using python and kivy using from tinydb import TinyD, Query
to import the tinydb
module. This works completely fine when testing my python and kivy code. After using buildozer to create an apk and debugging, it is saying that it crashed because of ImportError: no module named tinydb
. I tried adding tinydb
as a requiremenet in buildozer.spec
, but that did not fix it. I'm fairly certain that I need to install tinydb
in my App directory, this way the package is downloaded and included in my APK. However, I'm not quite sure how to do this. For example I installed the graph module from kivy garden using garden install --app graph
. If anyone has any suggestions that would be great!
Asked
Active
Viewed 1,178 times
0

Azaro
- 53
- 1
- 12
1 Answers
2
I've never used buildover but since tinydb is a tiny pure python library you could probably download and include the tinydb library directly in your project and import it locally.
I used the following directory structure
│ app.py
├───db
│ db.json
└───tinydb
│ database.py
│ middlewares.py
│ operations.py
│ queries.py
│ storages.py
│ utils.py
│ __init__.py
And main script app.py
from tinydb import TinyDB, Query
import os
dirname = os.path.dirname(os.path.abspath(__file__))
db = TinyDB(os.path.join(dirname, 'db', 'db.json'))

Tom Sitter
- 1,082
- 1
- 10
- 23
-
ok i'm still a little confused. How would I find the directory name for tinydb? Or rather the path? – Azaro Apr 29 '16 at 00:50
-
By putting the entire tinydb directory into my project folder, I was able to import it from app.py without issue -- python knows to look in the current directory for the library. You can download the repo from the [tinydb pypi page](https://pypi.python.org/pypi/tinydb) – Tom Sitter Apr 29 '16 at 00:59
-
Right so basically what i'm asking is how do you put the entire tinydb directory into the folder? Also i'm not entirely sure where the repo is on their page – Azaro Apr 29 '16 at 01:01
-
1Download the zip from the green download button, extract it, and copy the "tinydb" folder into your project. That's all I did to make my example work. – Tom Sitter Apr 29 '16 at 01:10
-
Thanks! One last question, do I put it just in the App folder or in the libs? – Azaro Apr 29 '16 at 01:19
-
That will depend on your project layout. I opted for a very simple one for this example, but if you have an existing lib folder you can put it in there and should be able to import it using `from lib.tinydb import TinyDB` – Tom Sitter Apr 29 '16 at 01:33
-
1If you put database.json in the same directory as the project, it will be deleted each time you update your application on the phone. To avoid this, you have to store the database on the SD card; but I guess it's another topic. – jligeza Apr 29 '16 at 06:57