There is more than one thing that you have to consider.
You cannot write in the file system so you cannot use required_folder so you have to change the settings of the app like this
This file is provided as an example:
"""
import os
# from py4web.core import required_folder
# db settings
APP_FOLDER = os.path.dirname(__file__)
APP_NAME = os.path.split(APP_FOLDER)[-1]
# DB_FOLDER: Sets the place where migration files will be created
# and is the store location for SQLite databases
DB_FOLDER = os.path.join(APP_FOLDER, "databases")
But in a way it works, I have deployed a simple app with it.
https://mereba.com You can even login if you have a
gmail.com address. Forms work fine, Grids don't. I use Datatables instead of Grid.
You cannot make all the queries like in web2py due to the joins and the or queries. In web2py the auth libraries work perfect with Datastore, but in py4web auth.py and some other utils do not prevent the use of that type of queries.
Here is the settings configuration to access the DB:
DB_FOLDER = os.path.join(APP_FOLDER, "databases")
# Separamos entorno de producción del local de desarrollo
if os.environ.get("GAE_ENV"):
DB_URI = "google:datastore"
DB_POOL_SIZE = 1
DB_MIGRATE = True
DB_FAKE_MIGRATE = False # maybe?
else:
DB_URI = "sqlite://storage.db"
DB_POOL_SIZE = 1
DB_MIGRATE = True
DB_FAKE_MIGRATE = False # maybe?
# location where static files are stored:
STATIC_FOLDER = os.path.join(APP_FOLDER, "static")
# location where to store uploaded files:
UPLOAD_FOLDER = os.path.join(APP_FOLDER, "uploads")
Luca is right Datastore is not the best option to have a more standar access to the data. Whenever I want to expor them I have to use hand made API REST. Py4web is good at API.
But I liked Datastore for simple apps because (I think) it is very robust in terms of security, I do not know of common threats that directly attack data in Datastore as there are for other databases.
Unfortunatly I can not use Datastore for "serious apps" with py4web yet.