Skip to content

Commit

Permalink
Reorganize and refactor DB API
Browse files Browse the repository at this point in the history
- Move corresponding code elements to a specific `src` directory
- Create `conn.py` to abstract DB connection functionality
  • Loading branch information
gabrielwong159 committed Jul 19, 2021
1 parent 3f42cf9 commit 7efd785
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 38 deletions.
33 changes: 0 additions & 33 deletions apis/db/psql/conn.py

This file was deleted.

5 changes: 3 additions & 2 deletions apis/db/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-cors
psycopg2-binary
docker
gunicorn
psycopg2
requests
2 changes: 1 addition & 1 deletion apis/db/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
gunicorn -b 127.0.0.1:8001 app:app
gunicorn -b 127.0.0.1:8001 --chdir src app:app
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions apis/db/src/psql/conn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import psycopg2
from typing import Tuple

DB_HOST = os.environ.get('DB_HOST', '127.0.0.1')
DB_PORT = os.environ.get('DB_PORT', 5432)


def get_connection():
conn = psycopg2.connect(dbname='evs',
user='postgres',
password='docker',
host=DB_HOST,
port=DB_PORT)
return conn
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions apis/db/psql/web.py → apis/db/src/psql/web.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import os
import requests

WEB_API_HOST = 'localhost'
WEB_API_PORT = 5000
WEB_API_HOST = os.environ.get('WEB_API_HOST', 'localhost')
WEB_API_PORT = os.environ.get('WEB_API_PORT', 5000)


def get_amount(username: str, password: str) -> float:
Expand Down

0 comments on commit 7efd785

Please sign in to comment.