小编Lau*_*nce的帖子

如何在AWS KMS中使用Boto3 download_file?

我有一个非常简单的脚本从桶中下载文件.该文件利用KMS加密密钥,我的策略和角色设置正确但我仍然收到错误.

#!/usr/bin/env python
import boto3
s3_client = boto3.client('s3')
s3_client.download_file('testtesttest', 'test.txt', '/tmp/test.txt')
Run Code Online (Sandbox Code Playgroud)

错误

Traceback (most recent call last):
  File "./getfile.py", line 4, in <module>
s3_client.download_file('testtesttest', 'test.txt', '/tmp/test.txt')
File "/usr/local/lib/python2.7/dist-packages/boto3/s3/inject.py", line 91, in download_file
extra_args=ExtraArgs, callback=Callback)
File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 659, in download_file
extra_args, callback)
File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 674, in _download_file
self._get_object(bucket, key, filename, extra_args, callback)
File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 698, in _get_object
extra_args, callback)
File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 712, in _do_get_object
**extra_args)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 301, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", …
Run Code Online (Sandbox Code Playgroud)

python amazon-s3 boto amazon-web-services

7
推荐指数
2
解决办法
6284
查看次数

如何将psycopg2连接字符串与变量一起使用?

我正在尝试使用以下变量连接到Postgres数据库:

cs = "dbname=%s user=%s password=%s host=%s port=%s",(dn,du,dp,dh,dbp)
con = None
con = psycopg2.connect(cs)
Run Code Online (Sandbox Code Playgroud)

但是我收到错误消息:

TypeError: argument 1 must be string, not tuple
Run Code Online (Sandbox Code Playgroud)

我需要能够在连接字符串中使用变量。有人知道如何做到这一点吗?

python postgresql psycopg2

3
推荐指数
1
解决办法
7407
查看次数