tombola / filemaker-sql

PoC to connect to FileMaker database via an ORM
MIT License
0 stars 0 forks source link

Load database connection from settings/env #8

Open tombola opened 11 months ago

tombola commented 11 months ago

Use pydantic settings to load from environment?

https://docs.pydantic.dev/latest/concepts/pydantic_settings/

Alternatively could load a dictionary from a python settings file? (eg django)

Bear in mind will want to support multiple databases.

tombola commented 11 months ago

On second thoughts, multiple databases doesn't need to be specifically handled in fmsql.

As long as can initialise an fmsql object with the required settings, and collect defaults/arguments from the environment for cli commands (which are against one dB) the client project can create several instances.


Could maybe just check whether it is possible to set the env_prefix for the nested settings model on init though? If so would give the option of getting settings for multiple dB from env. Eg:

FMSQL__DB__DBNAME__HOST

tombola commented 9 months ago

This looks brilliant for loading database and API instances

https://svcs.hynek.me/en/stable/

Might even handle closing database connection?

tombola commented 9 months ago

If use svcs then initially can just use it to load database in the same place as we do currently, and leave all the dependency injection in place.

After testing coverage is improved (in progress), can simplify by loading database service directly where needed, or in a decorator? (Would make the dependency more visible)