This is a demo application showing an approach to replicate the Cloudfarms data to a local database.
The Cloudfarms API provides a method do read data changes (upserts and deletes) and to store them in a local database.
This demo is implemented in Python and stores the data in a local database.
Set up the environment variables or provide the .env file
with the following entries:
CF_BASE_URL="https://pigs.cloudfarms.com"
CF_CLIENT_ID="your client id"
CF_CLIENT_SECRET="your client secret"The application will create all the needed tables and load the data from Cloudfarms. If the database already exits, the application load just the data changed since the last download.
By default, the database file is called farmSync.db. It is possible to rename the file by adding a command line argument with the name of the file.
Download the source code.
It is RECOMMENDED to create a virtual environment before installation as it allows for easier uninstallation:
It is possible to specify python version in all OS by appending the version after python. Ex: python3.9
Windows
Powershell
python -m venv .venv
.venv/scripts/Activate.ps1Command Prompt
python -m venv .venv
.venv/scripts/activate.batLinux/macOs
python3 -m venv .venv
source .venv/bin/activateYou can install the app using the following command:
pip install .or:
python -m pip install .Afterwards, run the app with the command:
my-appGlobal installation vs Virtual environment
If the app is installed globally, it should be possible to run the command from any directory
If the app is installed in a virtual environment, the command will only be available in the app directory