Hi, I've got 3 databases set up (master databases that is, postgres instances) as such: ``` master1: - db1: - tables... - db2: - and so on... - db3:
master2 master1: - db1: - tables... - db2: - and so on... - db3: master3 master2: - db1: - db2: - db3: ``` master3: - db1: - db2: - db3: SQLAlchemy Engine get the {master_i} part def sql_engine(passed_db_name, server_port): db_url = URL.create( "postgresql+psycopg2", username = os.getenv('DB_USER'), password = os.getenv('DB_PASS'), host = '127.0.0.1', port = int(server_port), database = str(**master_i**) # <<< Where I am using the path prefix {master_i} ) return create_engine(db_url)
def sql_engine(passed_db_name, server_port): db_url = URL.create( "postgresql+psycopg2", username = os.getenv('DB_USER'), password = os.getenv('DB_PASS'), host = '127.0.0.1', port = int(server_port), database = str(**master_i**) # <<< Where I am using the path prefix {master_i} ) return create_engine(db_url) and FastAPI gets the /db1/table1 @db1_router.get('/table_1') def get_table_1(): return [{"get": "sql_alchemy_output_from_{master_i}_here"}]
@db1_router.get('/table_1') def get_table_1(): return [{"get": "sql_alchemy_output_from_{master_i}_here"}]