Commit c4571c9f authored by Grant, Josh's avatar Grant, Josh
Browse files

working example with docker-compose

parent 1ca145b4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
*.sw[op]
# python build files
build/
__pycache__/
+7 −0
Original line number Diff line number Diff line
@@ -5,6 +5,13 @@ services:
    build: .
    volumes:
      - ./src/:/tmp/src
    environment:
      - DATABASE_HOST=postgres
      - DATABASE_TIMEOUT=60
    command:
      - 'tail'
      - '-f'
      - '/dev/null'

  postgres:
    image: postgres
+6 −4
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class Database(ABC):
    DEFAULT_TIMEOUT = ce('DATABASE_TIMEOUT', 60)
    DEFAULT_DB = ce('DATABASE_DB', 'postgres')
    DEFAULT_USER = ce('DATABASE_USER', 'postgres')
    DEFAULT_PW = ce('DATABASE_PW', 'posgres')
    DEFAULT_PW = ce('DATABASE_PW', 'postgres')
    DEFAULT_HOST = ce('DATABASE_HOST', "localhost")
    DEFAULT_PORT = int(ce('DATABASE_PORT', 5432))
    DEFAULT_SCHEMA = ce('DATABASE_SCHEMA', 'public')
@@ -156,9 +156,11 @@ class Database(ABC):
    def is_open(self):
        """Determine if the database is open or not."""
        # TODO @Jonathan -- code review please
        if self._cursor is not None and self._connection is not None: # Test if both connection and cursor are on
        if self._cursor is not None and self._connection is not None:
            # Test if both connection and cursor are on
            return True  # If both are on, return True
        return False # If one or both connection and cursor are missing, return False
        # If one or both connection and cursor are missing, return False
        return False

    def return_as_pandas(self, query):
        """ return a query as a pandas dataframe """