Ability for dynamic configuration through config files #508
Replies: 4 comments 2 replies
-
Yeah, it's a tricky one. For simple projects, you can just directly pass the database config to your DB = PostgresEngine(...)
class MyTable(db=DB):
... You have to be careful that there is only one # This would be problematic - we need one shared PostgresEngine for the entire application, so
# we can use a single connection pool
def get_engine():
return PostgresEngine(...)
class MyTable(db=get_engine()):
...
class MyOtherTable(db=get_engine()):
... For a more complex project, you currently need
At the moment, the migration code requires a One thing to be aware of, is you can customise the location of
In the future, it might be possible to have a from piccolo import Piccolo
Piccolo(db=PostgresEngine(...), app_config=AppConfig(...)) Then |
Beta Was this translation helpful? Give feedback.
-
@dantownsend This is what I did for making
Please let me know if this could result in some side-effects! Thanks |
Beta Was this translation helpful? Give feedback.
-
Similar to
|
Beta Was this translation helpful? Give feedback.
-
assuming
NOTE: Caveat, will only work if above folder structure |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice to be able to configure piccolo through runtime app configs instead of a conf file. It would help write framework specific extensions for piccolo.
E.g. flask_sqlalchemy https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/
If you write it as follows:
You can bypass piccolo_conf.py.
But then when running
piccolo migrations new home
it becomes a challenge, since it relies a lot on Finder looking for piccolo_conf.py.APP_REGISTRY: AppRegistry = Finder().get_app_registry()
engine = Finder().get_engine()
app_config = Finder().get_app_config(app_name=app_name)
If instead of looking up piccolo_conf.py module everytime, if we get to a state where it is read only once and engine and app_config are available everywhere else, one day we might be able to make piccolo_conf.py optional.
Beta Was this translation helpful? Give feedback.
All reactions