Load database credential from env variable.

        - host: ENV.{PREFIX}_HOST
        - port: ENV.{PREFIX}_PORT
        - database: ENV.{PREFIX}_DATABASE
        - username: ENV.{PREFIX}_USERNAME
        - password: ENV.{PREFIX}_PASSWORD

        :param prefix: str
        :param kms_decrypt: bool
        :param aws_profile: str

def from_env(cls, prefix, kms_decrypt=False, aws_profile=None):
        """
        Load database credential from env variable.

        - host: ENV.{PREFIX}_HOST
        - port: ENV.{PREFIX}_PORT
        - database: ENV.{PREFIX}_DATABASE
        - username: ENV.{PREFIX}_USERNAME
        - password: ENV.{PREFIX}_PASSWORD

        :param prefix: str
        :param kms_decrypt: bool
        :param aws_profile: str
        """
        if len(prefix) < 1:
            raise ValueError("prefix can't be empty")

        if len(set(prefix).difference(set(string.ascii_uppercase + "_"))):
            raise ValueError("prefix can only use [A-Z] and '_'!")

        if not prefix.endswith("_"):
            prefix = prefix + "_"

        data = dict(
            host=os.getenv(prefix + "HOST"),
            port=os.getenv(prefix + "PORT"),
            database=os.getenv(prefix + "DATABASE"),
            username=os.getenv(prefix + "USERNAME"),
            password=os.getenv(prefix + "PASSWORD"),
        )
        if kms_decrypt is True:  # pragma: no cover
            import boto3
            from base64 import b64decode

            if aws_profile is not None:
                kms = boto3.client("kms")
            else:
                ses = boto3.Session(profile_name=aws_profile)
                kms = ses.client("kms")

            def decrypt(kms, text):
                return kms.decrypt(
                    CiphertextBlob=b64decode(text.encode("utf-8"))
                )["Plaintext"].decode("utf-8")

            data = {
                key: value if value is None else decrypt(kms, str(value))
                for key, value in data.items()
            }

        return cls(**data)