From 6c03f2c7d0b9ede171850f5e520b2d7ac922caf8 Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Mon, 12 Aug 2024 16:06:50 -0700 Subject: [PATCH] Miscellaneous fixes - Add `lending/create_db.sh` to create dev/test databases - Add separate `dev` environment in domain.toml. When env is unspecified, `memory` is the provider. - Choose database 2 for local redis dev testing --- README.md | 10 ++++++++++ src/catalogue/main.py | 2 +- src/lending/create_db.sh | 43 ++++++++++++++++++++++++++++++++++++++++ src/lending/domain.toml | 24 +++++++++++++++------- 4 files changed, 71 insertions(+), 8 deletions(-) create mode 100755 src/lending/create_db.sh diff --git a/README.md b/README.md index fa8572d..c52d0d8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,16 @@ Protean example implementation `pre-commit install` +## Running Development Servers + +1. Catalogue domain: + + FastAPI Server: `fastapi dev src/catalogue/main.py` + +1. Lending domain: + + Protean Server: `PROTEAN_ENV=dev protean server --domain lending.domain` + ## Running Tests - Basic: `make test` diff --git a/src/catalogue/main.py b/src/catalogue/main.py index e6a9fea..9b949eb 100644 --- a/src/catalogue/main.py +++ b/src/catalogue/main.py @@ -18,7 +18,7 @@ # Redis setup def get_redis_client(): - return redis.Redis(host="localhost", port=6379, db=0) + return redis.Redis(host="localhost", port=6379, db=2) def get_db(): diff --git a/src/lending/create_db.sh b/src/lending/create_db.sh new file mode 100755 index 0000000..d063c73 --- /dev/null +++ b/src/lending/create_db.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Variables for database connection +DB_HOST="localhost" +DB_PORT="5432" +DB_ADMIN="postgres" # The database admin user (e.g., 'postgres') +DB_ADMIN_PASSWORD="postgres" + +# Variables for the new user and database +DB_NAME="local_postgres" +DB_USER="local_postgres" +DB_USER_PASSWORD="local_postgres" + +# SQL commands to create the user +SQL_CREATE_USER=$(cat <