相关疑难解决方法(0)

使用psycopg2和Lambda来更新Redshift(Python)

我试图使用python从Lambda函数更新Redshift.为此,我试图合并两个代码片段.当我单独运行它们时,两个片段都是有效的.

  1. 从PyDev for Eclipse更新Redshift

    import psycopg2
    
    conn_string = "dbname='name' port='0000' user='name' password='pwd' host='url'"
    conn = psycopg2.connect(conn_string)
    
    cursor = conn.cursor()
    
    cursor.execute("UPDATE table SET attribute='new'")
    conn.commit()
    cursor.close()
    
    Run Code Online (Sandbox Code Playgroud)
  2. 接收上载到S3存储桶的内容(Lambda上可用的预制模板)

    from __future__ import print_function
    
    import json
    import urllib
    import boto3
    
    print('Loading function')
    
    s3 = boto3.client('s3')
    
    
    def lambda_handler(event, context):
        #print("Received event: " + json.dumps(event, indent=2))
    
        # Get the object from the event and show its content type
        bucket = event['Records'][0]['s3']['bucket']['name']
        key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')
    
        try:
            response = s3.get_object(Bucket=bucket, Key=key)
            print("CONTENT TYPE: " + response['ContentType'])
            return response['ContentType'] …
    Run Code Online (Sandbox Code Playgroud)

python amazon-web-services amazon-redshift aws-sdk aws-lambda

10
推荐指数
5
解决办法
2万
查看次数

AWS Glue psycopg2 安装

我正在尝试运行使用 psycopg2 操作 Redshift 实例的代码。我尝试导入一个wheel文件,因为我发现它们在Glue python作业中受支持。我在运行时看到该库已安装在端点中,但随后出现错误:

import boto3
import psycopg2
Run Code Online (Sandbox Code Playgroud)
Aug 4, 2020, 1:24:06 PM Pending execution
Processing ./glue-python-libs-92ng4pcb/psycopg2-2.8.5-cp36-cp36m-win_amd64.whl
Installing collected packages: psycopg2
Successfully installed psycopg2-2.8.5
Considering file without prefix as a python extra file s3://gluelibraries/boto3.zip
Run Code Online (Sandbox Code Playgroud)
WARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

2020-08-04T13:24:44.831+02:00 …
Run Code Online (Sandbox Code Playgroud)

python psycopg2 amazon-web-services aws-glue

5
推荐指数
2
解决办法
1万
查看次数

没有名为psycopg2的模块

我有使用postgresql 9的Django项目.我安装了psycopg2,当我运行项目时,我收到'错误加载psycopg2模块:dll加载失败'.我第一次遇到这个问题.我有Windows 7 x64与python2.7.我怎么解决这个?

python django psycopg2 windows-7

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