我正在尝试从 AWS Glue 访问 RDS 实例,我在 EC2 实例中运行了一些 Python 脚本,并且我目前使用 PYODBC 进行连接,但是在尝试为胶水安排作业时,我无法导入 PYODBC,因为 AWS 本身不支持它胶水,不确定驱动程序如何在胶水外壳中工作。
我在 AWS Glue 中有以下工作,它基本上从一个表中读取数据并将其提取为 S3 中的 csv 文件,但是我想在这个表上运行查询(A Select、SUM 和 GROUPBY)并希望得到该输出CSV,如何在 AWS Glue 中执行此操作?我是 Spark 的新手,所以请帮忙
args = getResolvedOptions(sys.argv, ['JOB_NAME'])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args['JOB_NAME'], args)
datasource0 = glueContext.create_dynamic_frame.from_catalog(database =
"db1", table_name = "dbo1_expdb_dbo_stg_plan", transformation_ctx =
"datasource0")
applymapping1 = ApplyMapping.apply(frame = datasource0, mappings =
[("plan_code", "int", "plan_code", "int"), ("plan_id", "int", "plan_id",
"int")], transformation_ctx = "applymapping1")
datasink2 = glueContext.write_dynamic_frame.from_options(frame =
applymapping1, connection_type = "s3", connection_options = {"path":
"s3://bucket"}, format = "csv", transformation_ctx = …Run Code Online (Sandbox Code Playgroud) 我尝试不为配置文件使用绝对路径,因为我需要在多个环境中部署该路径,这是我的最佳选择
以下代码是我尝试过的代码,它无法找到路径,但是我可以将文件放在同一位置。我在Redhat服务器上使用Python3.6。
with open("~/scripts/config.yml", 'r') as ymlfile:
cfg = yaml.load(ymlfile)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '~/scripts/config.yml'
Run Code Online (Sandbox Code Playgroud)