lambdas/setup_upload_artifacts/artifacts/glue_load_station_history_redshift.py [11:53]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class rs_common:
  # Returns connection and credential information from secrets manager
  @staticmethod
  def connection_info(db_creds):
    session = boto3.session.Session()
    client = session.client(
      service_name='secretsmanager'
    )

    get_secret_value_response = client.get_secret_value(SecretId=db_creds)

    if 'SecretString' in get_secret_value_response:
      secret = json.loads(get_secret_value_response['SecretString'])
    else:
      secret = json.loads(base64.b64decode(get_secret_value_response['SecretBinary']))
      
    return secret

  # Returns a connection to the cluster
  @staticmethod
  def get_connection(db_creds):

    con_params = rs_common.connection_info(db_creds)
    
    rs_conn_string = "host=%s port=%s dbname=%s user=%s password=%s" % (con_params['host'], con_params['port'], con_params['dbname'], con_params['username'], con_params['password'])
    rs_conn = pg.connect(dbname=rs_conn_string)
    rs_conn.query("set statement_timeout = 1200000")
    
    return rs_conn

  # Submits a query to the cluster
  @staticmethod
  def query(con,statement):
      res = con.query(statement)
      return res
    
# Get job args
args = getResolvedOptions(sys.argv,['db_creds','glue_db'])
db_creds = args['db_creds']
glue_db = args['glue_db']

sql = '''
BEGIN;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



lambdas/setup_upload_artifacts/artifacts/glue_load_station_review_redshift.py [11:53]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class rs_common:
  # Returns connection and credential information from secrets manager
  @staticmethod
  def connection_info(db_creds):
    session = boto3.session.Session()
    client = session.client(
      service_name='secretsmanager'
    )

    get_secret_value_response = client.get_secret_value(SecretId=db_creds)

    if 'SecretString' in get_secret_value_response:
      secret = json.loads(get_secret_value_response['SecretString'])
    else:
      secret = json.loads(base64.b64decode(get_secret_value_response['SecretBinary']))
      
    return secret

  # Returns a connection to the cluster
  @staticmethod
  def get_connection(db_creds):

    con_params = rs_common.connection_info(db_creds)
    
    rs_conn_string = "host=%s port=%s dbname=%s user=%s password=%s" % (con_params['host'], con_params['port'], con_params['dbname'], con_params['username'], con_params['password'])
    rs_conn = pg.connect(dbname=rs_conn_string)
    rs_conn.query("set statement_timeout = 1200000")
    
    return rs_conn

  # Submits a query to the cluster
  @staticmethod
  def query(con,statement):
      res = con.query(statement)
      return res
    
# Get job args
args = getResolvedOptions(sys.argv,['db_creds','glue_db'])
db_creds = args['db_creds']
glue_db = args['glue_db']

sql = '''
BEGIN;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



